@@ -29,6 +29,7 @@ import Registry.PackageName as PackageName
29
29
import Spago.Command.Fetch as Fetch
30
30
import Spago.Config (Package (..), WithTestGlobs (..), WorkspacePackage )
31
31
import Spago.Config as Config
32
+ import Spago.FS as FS
32
33
import Spago.Glob as Glob
33
34
import Spago.Log as Log
34
35
import Spago.Path as Path
@@ -96,10 +97,26 @@ getModuleGraphWithPackage (ModuleGraph graph) = do
96
97
$ for (Map .toUnfoldable allPackages)
97
98
\(Tuple name package) -> do
98
99
-- Basically partition the modules of the current package by in src and test packages
99
- let withTestGlobs = if (Set .member name ( Map .keys testPackages) ) then OnlyTestGlobs else NoTestGlobs
100
+ let withTestGlobs = if (Map .member name testPackages) then OnlyTestGlobs else NoTestGlobs
100
101
logDebug $ " Getting globs for package " <> PackageName .print name
101
- globMatches :: Array LocalPath <- map Array .fold $ traverse compileGlob (Config .sourceGlob rootPath withTestGlobs name package)
102
- pure $ map (\p -> Tuple p name) globMatches
102
+
103
+ -- We have to glob this package's sources relative to its own root,
104
+ -- not to our workspace root, because the package may be located
105
+ -- outside of the workspace root - e.g. if it's a local-file-system
106
+ -- package, - in which case the `gitignoringGlob` function won't match
107
+ -- any files there. That's just how it works: it walks down the tree
108
+ -- from the given root.
109
+ packageRoot <- Path .mkRoot $ Config .getLocalPackageLocation rootPath name package
110
+ packageExists <- FS .exists packageRoot
111
+
112
+ if packageExists then
113
+ Config .sourceGlob rootPath withTestGlobs name package
114
+ <#> (_ `Path.relativeTo` packageRoot)
115
+ # traverse (compileGlob packageRoot)
116
+ <#> Array .fold
117
+ <#> map \p -> (p `Path.relativeTo` rootPath) /\ name
118
+ else
119
+ pure []
103
120
104
121
logDebug " Got the pathToPackage map, calling packageGraph"
105
122
let
@@ -118,10 +135,9 @@ getModuleGraphWithPackage (ModuleGraph graph) = do
118
135
119
136
pure packageGraph
120
137
121
- compileGlob :: ∀ a . LocalPath -> Spago { rootPath :: RootPath | a } (Array LocalPath )
122
- compileGlob sourcePath = do
123
- { rootPath } <- ask
124
- liftAff $ Glob .gitignoringGlob
138
+ compileGlob :: ∀ a . RootPath -> LocalPath -> Spago { rootPath :: RootPath | a } (Array LocalPath )
139
+ compileGlob rootPath sourcePath = liftAff $
140
+ Glob .gitignoringGlob
125
141
{ root: rootPath
126
142
, includePatterns: [ Path .localPart $ withForwardSlashes sourcePath ]
127
143
, ignorePatterns: []
@@ -233,7 +249,7 @@ checkImports graph = do
233
249
{ rootPath } <- ask
234
250
projectFiles :: Set String <-
235
251
Config .sourceGlob rootPath testGlobOption packageName (WorkspacePackage selected)
236
- # traverse compileGlob
252
+ # traverse ( compileGlob rootPath)
237
253
<#> Array .fold
238
254
<#> map (Path .localPart <<< withForwardSlashes)
239
255
<#> Set .fromFoldable
@@ -324,7 +340,7 @@ unusedError isTest selected unused = do
324
340
{ errorMessage: toDoc
325
341
[ toDoc $ (if isTest then " Tests for package '" else " Sources for package '" )
326
342
<> PackageName .print selected.package.name
327
- <> " ' declares unused dependencies - please remove them from the project config:"
343
+ <> " ' declare unused dependencies - please remove them from the project config:"
328
344
, indent $ toDoc $ map (append " - " ) unusedPkgs
329
345
]
330
346
, correction: toDoc
0 commit comments