Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse absolute globs to watch relative paths in source configs #556

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ New features:
- Allow `verify-set` to work with either a `spago.dhall` or a `packages.dhall` (#515)
- Fix typo on `packages.dhall` template (`let override` should be `let overrides`)

Bugfixes:
- Fix watching relative paths in sources config (e.g. `../src/**/*.purs`) (#556)

## [0.13.1] - 2020-01-10

New features:
Expand Down
13 changes: 7 additions & 6 deletions src/Spago/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ build buildOpts@BuildOptions{..} maybePostBuild = do
let allPsGlobs = Packages.getGlobs deps depsOnly configSourcePaths <> sourcePaths
allJsGlobs = Packages.getJsGlobs deps depsOnly configSourcePaths <> sourcePaths

buildBackend globs = do
buildBackend globs = do
case alternateBackend of
Nothing ->
Purs.compile globs sharedOutputArgs
Expand Down Expand Up @@ -142,7 +142,7 @@ build buildOpts@BuildOptions{..} maybePostBuild = do
absoluteJSGlobs <- traverse makeAbsolute jsMatches

Watch.watch
(Set.fromAscList $ fmap Glob.compile . removeDotSpago $ absolutePSGlobs <> absoluteJSGlobs)
(Set.fromAscList $ fmap (Glob.compile . collapse) . removeDotSpago $ absolutePSGlobs <> absoluteJSGlobs)
shouldClear
(buildAction (wrap <$> psMatches))

Expand All @@ -167,6 +167,7 @@ build buildOpts@BuildOptions{..} maybePostBuild = do
wrap = Purs.SourcePath . Text.pack
unwrap = Text.unpack . Purs.unSourcePath
removeDotSpago = filter (\glob -> ".spago" `notElem` (splitDirectories glob))
collapse = Turtle.encodeString . Turtle.collapse . Turtle.decodeString

-- | Start a repl
repl
Expand Down Expand Up @@ -404,25 +405,25 @@ data PathType
showOutputPath
:: BuildOptions
-> Spago ()
showOutputPath buildOptions =
showOutputPath buildOptions =
outputStr =<< getOutputPathOrDefault buildOptions

showPaths
:: BuildOptions
-> Maybe PathType
-> Spago ()
showPaths buildOptions whichPaths =
showPaths buildOptions whichPaths =
case whichPaths of
(Just OutputFolder) -> showOutputPath buildOptions
Nothing -> showAllPaths buildOptions

showAllPaths
:: BuildOptions
-> Spago ()
showAllPaths buildOptions =
showAllPaths buildOptions =
traverse_ showPath =<< getAllPaths buildOptions
where
showPath (a,b)
showPath (a,b)
= output (a <> ": " <> b)

getAllPaths
Expand Down