diff --git a/Changelog.md b/Changelog.md index 03ddb45e3..aedfb3a7f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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)) diff --git a/src/Strategy/Leiningen.hs b/src/Strategy/Leiningen.hs index dd787f23d..fd360825e 100644 --- a/src/Strategy/Leiningen.hs +++ b/src/Strategy/Leiningen.hs @@ -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 @@ -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