Skip to content

Commit

Permalink
Don't warn on unused deps when building --deps-only (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwolverson authored Jun 13, 2021
1 parent 96ea7fe commit 8b8f06a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Bugfixes:
- Don't warn on unused deps when building --deps-only. (#794)

## [0.20.3] - 2021-05-12

Bugfixes:
- Fix `docs` command error due to bad templates (#792)

Expand Down
2 changes: 1 addition & 1 deletion src/Spago/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ build maybePostBuild = do
$ Set.toList
$ Set.difference importedPackages dependencyPackages

unless (null unusedPackages) $ do
unless (null unusedPackages || depsOnly == DepsOnly) $ do
logWarn $ display $ Messages.unusedDependency unusedPackages

unless (null transitivePackages) $ do
Expand Down
1 change: 1 addition & 0 deletions src/Spago/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ data PathType

-- | Only build deps and ignore project paths
data DepsOnly = DepsOnly | AllSources
deriving (Eq)

data Watch = Watch | BuildOnce

Expand Down
3 changes: 3 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ flags:
haskeline:
terminfo: false
examples: false
cryptonite:
use_target_attributes: false

10 changes: 10 additions & 0 deletions test/SpagoSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,16 @@ spec = around_ setup $ do
spago ["build"]
spago ["--no-psa", "build"] >>= shouldBeSuccessStderr "check-unused-dependency.txt"

it "Spago should not warn on unused dependencies when building deps-only" $ do
spago ["init"] >>= shouldBeSuccess
rm "spago.dhall"
writeTextFile "spago.dhall" $ "{ name = \"check-imports\", dependencies = [\"effect\", \"prelude\"], packages = ./packages.dhall }"
rm "src/Main.purs"
writeTextFile "src/Main.purs" "module Main where\nimport Prelude\nmain :: Unit\nmain = unit"
rm "test/Main.purs"
spago ["build"]
spago ["--no-psa", "build", "--deps-only"] >>= shouldBeSuccessStderr "spago-build-succeeded-stderr.txt"

describe "alternate backend" $ do

it "Spago should use alternate backend if option is specified" $ do
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/spago-build-succeeded-stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[info] Build succeeded.

0 comments on commit 8b8f06a

Please sign in to comment.