Skip to content

Commit 5042ae2

Browse files
authored
Print install command to fix missing transitive dependencies (#770)
1 parent 098f1d3 commit 5042ae2

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Other improvements:
1414
- Color output is now automatically disabled when output is redirected to a file.
1515
Also respects a [`NO_COLOR`](https://no-color.org/) environment variable (#768)
1616
- Fixes tests failing if the test platform has psa installed (#772)
17+
- Print `spago install` command to fix missing transitive dependencies (#770)
1718

1819
## [0.20.0] - 2021-04-07
1920

src/Spago/Messages.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,5 @@ sourceImportsTransitiveDependency transitive = makeMessage $
242242
[ "Some of your project files import modules from packages that are not in the direct dependencies of your project."
243243
, "To fix this error add the following packages to the list of dependencies in your config:"
244244
] <> map (\package -> "- " <> package) transitive
245+
<> [ "You may add these dependencies by running the following command:"
246+
, "spago install " <> Text.intercalate " " transitive ]

test/SpagoSpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,9 @@ spec = around_ setup $ do
425425
it "Spago should fail on direct project imports from transitive dependencies" $ do
426426
spago ["init"] >>= shouldBeSuccess
427427
rm "spago.dhall"
428-
writeTextFile "spago.dhall" $ "{ name = \"check-imports\", dependencies = [\"effect\"], packages = ./packages.dhall }"
428+
writeTextFile "spago.dhall" $ "{ name = \"check-imports\", dependencies = [\"effect\", \"lists\"], packages = ./packages.dhall }"
429429
rm "src/Main.purs"
430-
writeTextFile "src/Main.purs" "module Main where\nimport Prelude\nmain = unit"
430+
writeTextFile "src/Main.purs" "module Main where\nimport Prelude\nimport Data.Maybe\nimport Data.List\nmain = unit"
431431
rm "test/Main.purs"
432432
spago ["build"]
433433
spago ["--no-psa", "build"] >>= shouldBeFailureStderr "check-direct-import-transitive-dependency.txt"

test/fixtures/check-direct-import-transitive-dependency.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ These dependencies are unused. To fix this warning, remove the following package
55
- effect
66
[error] Some of your project files import modules from packages that are not in the direct dependencies of your project.
77
To fix this error add the following packages to the list of dependencies in your config:
8+
- maybe
89
- prelude
10+
You may add these dependencies by running the following command:
11+
spago install maybe prelude

0 commit comments

Comments
 (0)