Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
Fixes lein analysis for common CI workflows (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
meghfossa authored Sep 28, 2021
1 parent 40008c0 commit 86bc410
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Spectrometer Changelog

## v2.15.24
- Leiningen: Executes `lein --version` before performing any analysis, to ensure Leiningen has performed its install tasks (done on its first invocation). ([#379](https://github.com/fossas/spectrometer/pull/379))

## v2.15.23
- Maven: Fixes `mvn:dependency` tactic to exclude root project as direct dependency. ([#375](https://github.com/fossas/spectrometer/pull/375))

Expand Down
13 changes: 13 additions & 0 deletions src/Strategy/Leiningen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ leinDepsCmd =
, cmdAllowErr = Never
}

leinVersionCmd :: Command
leinVersionCmd =
Command
{ cmdName = "lein"
, cmdArgs = ["--version"]
, cmdAllowErr = Always
}

discover :: (Has ReadFS sig m, Has Diagnostics sig m, Has Exec rsig run, Has Diagnostics rsig run) => Path Abs Dir -> m [DiscoveredProject run]
discover dir = context "Leiningen" $ do
projects <- context "Finding projects" $ findProjects dir
Expand Down Expand Up @@ -89,6 +97,11 @@ data LeiningenProject = LeiningenProject

analyze :: (Has Exec sig m, Has Diagnostics sig m) => Path Abs File -> m DependencyResults
analyze file = do
-- Lein executable performs configuration task and prints its progress on the first invocation.
-- Intentionally invoke --version command to ensure subsequent analyses command are not lein's first invocation.
-- This ensures, subsequent analyzes commands' outputs are not contaminated with lein's configuration task's output.
_ <- exec (parent file) leinVersionCmd

stdoutBL <- execThrow (parent file) leinDepsCmd
let stdoutTL = decodeUtf8 stdoutBL
stdout = TL.toStrict stdoutTL
Expand Down

0 comments on commit 86bc410

Please sign in to comment.