@@ -38,7 +38,7 @@ import Data.Enum as Enum
38
38
import Data.Graph as Graph
39
39
import Data.HTTP.Method as Method
40
40
import Data.Int as Int
41
- import Data.List (List (..), (:) )
41
+ import Data.List (List (..))
42
42
import Data.Map as Map
43
43
import Data.Nullable (Nullable )
44
44
import Data.Nullable as Nullable
@@ -48,7 +48,6 @@ import Data.Set.NonEmpty (NonEmptySet)
48
48
import Data.Set.NonEmpty as NonEmptySet
49
49
import Data.String (CodePoint , Pattern (..))
50
50
import Data.String as String
51
- import Data.Traversable (sequence )
52
51
import Dodo as Log
53
52
import Effect.Aff as Aff
54
53
import Effect.Uncurried (EffectFn2 , EffectFn3 , runEffectFn2 , runEffectFn3 )
@@ -201,27 +200,30 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
201
200
checkForWorkspace :: forall a . FilePath
202
201
-> Spago (LogEnv a ) (Maybe PrelimWorkspace )
203
202
checkForWorkspace config = do
204
- result <- readConfig config
203
+ logInfo $ " Checking for workspace: " <> config
204
+ result <- map (map (\y -> y.yaml)) $ readConfig config
205
205
case result of
206
206
Left _ -> pure Nothing
207
- Right { yaml: { workspace: Nothing } } -> pure Nothing
208
- Right { yaml: { workspace: Just ws } } -> pure (Just ws)
207
+ Right { workspace: Nothing } -> pure Nothing
208
+ Right { workspace: Just ws } -> pure (Just ws)
209
209
210
- searchHigherPaths :: forall a . List FilePath -> Spago (LogEnv a ) (Maybe PrelimWorkspace )
210
+ searchHigherPaths :: forall a . List FilePath -> Spago (LogEnv a ) (Maybe ( Tuple FilePath PrelimWorkspace ) )
211
211
searchHigherPaths Nil = pure Nothing
212
212
searchHigherPaths (path : otherPaths) = do
213
- mYaml :: Maybe String <- map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./spago.yaml" ]
213
+ -- TODO stop searching if .git is found, this is the root
214
+ logInfo $ " Searching " <> path
215
+ mYaml :: Maybe String <- map (map (\yml -> path <> yml)) $ map Array .head $ liftAff $ Glob .gitignoringGlob path [ " ./spago.yaml" ]
214
216
case mYaml of
215
217
Nothing -> searchHigherPaths otherPaths
216
218
Just foundSpagoYaml -> do
217
219
mWorkspace :: Maybe PrelimWorkspace <- checkForWorkspace foundSpagoYaml
218
220
case mWorkspace of
219
221
Nothing -> searchHigherPaths otherPaths
220
- workspace -> pure workspace
222
+ Just ws -> pure (pure ( Tuple foundSpagoYaml ws))
221
223
222
- mHigherConfigPath <- searchHigherPaths higherPaths
223
- for_ mHigherConfigPath $ \higherConfigPath -> do
224
- logDebug $ [ toDoc " Found workspace at higher path: " ]
224
+ mHigherWorkspace <- searchHigherPaths higherPaths
225
+ for_ mHigherWorkspace $ \( Tuple filepath _) ->
226
+ logInfo $ " Found workspace definition in " <> filepath
225
227
226
228
-- First try to read the config in the root. It _has_ to contain a workspace
227
229
-- configuration, or we fail early.
@@ -234,10 +236,16 @@ readWorkspace { maybeSelectedPackage, pureBuild, migrateConfig } = do
234
236
, Log .break
235
237
, toDoc " The configuration file help can be found here https://github.com/purescript/spago#the-configuration-file"
236
238
]
237
- Right { yaml: { workspace: Nothing } } -> die
238
- [ " Your spago.yaml doesn't contain a workspace section."
239
- , " See the relevant documentation here: https://github.com/purescript/spago#the-workspace"
240
- ]
239
+ Right config@{ yaml: { workspace: Nothing , package }, doc } -> case mHigherWorkspace of
240
+ Nothing ->
241
+ die
242
+ [ " No workspace definition found in this spago.yaml or any spago.yaml in parent directory."
243
+ , " See the relevant documentation here: https://github.com/purescript/spago#the-workspace"
244
+ ]
245
+ Just (Tuple _ higherWorkspace) -> do
246
+ -- TODO migrate workspace at higher directory?
247
+ doMigrateConfig " spago.yaml" config
248
+ pure { workspace: higherWorkspace, package, workspaceDoc: doc }
241
249
Right config@{ yaml: { workspace: Just workspace, package }, doc } -> do
242
250
doMigrateConfig " spago.yaml" config
243
251
pure { workspace, package, workspaceDoc: doc }
0 commit comments