@@ -182,9 +182,13 @@ discoverWorkspace options cwd = do
182182 logInfo " Reading Spago workspace configuration..."
183183 logDebug $ " Discovering nearest workspace " <> spagoYaml <> " starting at " <> Path .quote cwd
184184
185- { workspace, rootPath } /\ { loadedPackages, closestPackage } <-
185+ { workspace, rootPath } /\ upTree@{ closestPackage } <-
186186 State .runStateT (walkDirectoriesUpFrom cwd)
187- { loadedPackages: Map .empty, otherWorkspaceRoots: [] , misnamedConfigs: [] , closestPackage: Nothing }
187+ { loadedPackages: Map .empty, misnamedConfigs: [] , closestPackage: Nothing }
188+
189+ { loadedPackages } <-
190+ State .execStateT (loadSubprojectConfigs rootPath)
191+ { loadedPackages: upTree.loadedPackages, blockedSubtrees: [] }
188192
189193 migrateConfigsWhereNeeded rootPath loadedPackages
190194
@@ -229,6 +233,7 @@ discoverWorkspace options cwd = do
229233 }
230234 }
231235 where
236+ readConfig' :: ∀ s . _ -> State.StateT s _ _
232237 readConfig' = State .lift <<< readConfig
233238
234239 walkDirectoriesUpFrom dir = do
@@ -249,7 +254,6 @@ discoverWorkspace options cwd = do
249254 Just { doc, yaml: { workspace: Just workspace, package } } -> do
250255 -- Finally, found the "workspace" config!
251256 rootPath <- Path .mkRoot dir
252- loadSubprojectConfigs rootPath
253257 pure { workspace: { config: workspace, doc, rootPackage: package }, rootPath }
254258 _ -> do
255259 -- No workspace in this directory => recur to parent directory (unless it's already root)
@@ -277,19 +281,20 @@ discoverWorkspace options cwd = do
277281 let
278282 configFile = dir </> spagoYaml
279283 alreadyLoaded = st.loadedPackages # Map .member configFile
280- anotherParentWorkspace = st.otherWorkspaceRoots # Array .find (_ `Path.isPrefixOf` dir)
281- case alreadyLoaded, anotherParentWorkspace of
284+ blockedSubtree = st.blockedSubtrees # Array .find (_ `Path.isPrefixOf` dir)
285+ case alreadyLoaded, blockedSubtree of
282286 true , _ ->
283287 pure unit
284- _, Just ws -> do
285- logDebug $ " Not trying to load " <> Path .quote configFile <> " because it belongs to a different workspace at " <> Path .quote ws
288+ _, Just b -> do
289+ logDebug $ " Not trying to load " <> Path .quote configFile <> " because it is nested under " <> Path .quote b
286290 pure unit
287291 false , Nothing ->
288292 readConfig' configFile >>= case _ of
289- Left _ ->
290- logWarn $ " Failed to read config at " <> Path .quote configFile
293+ Left _ -> do
294+ logWarn [ " Failed to read config at " <> Path .quote configFile, " Skipping it and all its subprojects" ]
295+ State .modify_ \s -> s { blockedSubtrees = Array .cons dir s.blockedSubtrees }
291296 Right { yaml: { workspace: Just _ } } ->
292- State .modify_ \s -> s { otherWorkspaceRoots = Array .cons dir s.otherWorkspaceRoots }
297+ State .modify_ \s -> s { blockedSubtrees = Array .cons dir s.blockedSubtrees }
293298 Right config@{ yaml: { package: Just package } } -> do
294299 logDebug $ " Loaded a subproject config at " <> Path .quote configFile
295300 State .modify_ \s -> s { loadedPackages = Map .insert dir { package, config } s.loadedPackages }
0 commit comments