Skip to content

Commit

Permalink
execArgs -> exec_args
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashoneyman committed Oct 23, 2023
1 parent 861abb5 commit 704baee
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 77 deletions.
142 changes: 88 additions & 54 deletions README.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions bin/src/Flags.purs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ pursArgs =
)
)

execArgs :: Parser (Maybe (Array String))
execArgs =
exec_args :: Parser (Maybe (Array String))
exec_args =
OT.optional
$ Array.fromFoldable
<$> O.many
Expand Down Expand Up @@ -285,4 +285,3 @@ depsOnly =
( O.long "deps-only"
<> O.help "Build depedencies only"
)

16 changes: 8 additions & 8 deletions bin/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ type RunArgs =
, pedanticPackages :: Boolean
, pursArgs :: List String
, backendArgs :: List String
, execArgs :: Maybe (Array String)
, exec_args :: Maybe (Array String)
, main :: Maybe String
, ensureRanges :: Boolean
, strict :: Maybe Boolean
Expand All @@ -136,7 +136,7 @@ type TestArgs =
, pedanticPackages :: Boolean
, pursArgs :: List String
, backendArgs :: List String
, execArgs :: Maybe (Array String)
, exec_args :: Maybe (Array String)
, strict :: Maybe Boolean
, statVerbosity :: Maybe Core.StatVerbosity
}
Expand Down Expand Up @@ -330,7 +330,7 @@ runArgsParser = Optparse.fromRecord
{ selectedPackage: Flags.selectedPackage
, pursArgs: Flags.pursArgs
, backendArgs: Flags.backendArgs
, execArgs: Flags.execArgs
, exec_args: Flags.exec_args
, output: Flags.output
, pedanticPackages: Flags.pedanticPackages
, main: Flags.moduleName
Expand All @@ -344,7 +344,7 @@ testArgsParser = Optparse.fromRecord
{ selectedPackage: Flags.selectedPackage
, pursArgs: Flags.pursArgs
, backendArgs: Flags.backendArgs
, execArgs: Flags.execArgs
, exec_args: Flags.exec_args
, output: Flags.output
, pedanticPackages: Flags.pedanticPackages
, strict: Flags.strict
Expand Down Expand Up @@ -740,11 +740,11 @@ mkRunEnv runArgs { dependencies, purs } = do
runConf f = selected.package.run >>= f

moduleName = fromMaybe "Main" (runArgs.main <|> runConf _.main)
execArgs = fromMaybe [] (runArgs.execArgs <|> runConf _.execArgs)
exec_args = fromMaybe [] (runArgs.exec_args <|> runConf _.exec_args)

runOptions =
{ moduleName
, execArgs
, exec_args
, sourceDir: Paths.cwd
, executeDir: Paths.cwd
, successMessage: Nothing
Expand All @@ -770,10 +770,10 @@ mkTestEnv testArgs { dependencies, purs } = do
testConf f = selected.package.test >>= f

moduleName = fromMaybe "Test.Main" (testConf (_.main >>> Just))
execArgs = fromMaybe [] (testArgs.execArgs <|> testConf _.execArgs)
exec_args = fromMaybe [] (testArgs.exec_args <|> testConf _.exec_args)
in
{ moduleName
, execArgs
, exec_args
, selected
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ publishConfigCodec = CA.object "PublishConfig"

type RunConfig =
{ main :: Maybe String
, execArgs :: Maybe (Array String)
, exec_args :: Maybe (Array String)
}

runConfigCodec :: JsonCodec RunConfig
runConfigCodec = CA.object "RunConfig"
$ CA.recordPropOptional (Proxy :: _ "main") CA.string
$ CA.recordPropOptional (Proxy :: _ "execArgs") (CA.array CA.string)
$ CA.recordPropOptional (Proxy :: _ "exec_args") (CA.array CA.string)
$ CA.record

type TestConfig =
{ main :: String
, execArgs :: Maybe (Array String)
, exec_args :: Maybe (Array String)
, dependencies :: Dependencies
, censor_test_warnings :: Maybe CensorBuildWarnings
, strict :: Maybe Boolean
Expand All @@ -132,7 +132,7 @@ type TestConfig =
testConfigCodec :: JsonCodec TestConfig
testConfigCodec = CA.object "TestConfig"
$ CA.recordProp (Proxy :: _ "main") CA.string
$ CA.recordPropOptional (Proxy :: _ "execArgs") (CA.array CA.string)
$ CA.recordPropOptional (Proxy :: _ "exec_args") (CA.array CA.string)
$ CA.recordPropOptional (Proxy :: _ "censor_test_warnings") censorBuildWarningsCodec
$ CA.recordPropOptional (Proxy :: _ "strict") CA.boolean
$ CA.recordPropOptional (Proxy :: _ "pedantic_packages") CA.boolean
Expand Down
2 changes: 1 addition & 1 deletion src/Spago/Command/Init.purs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ defaultConfig' opts =
, run: Nothing
, test: test <#> \{ moduleMain, censorTestWarnings, strict, pedanticPackages, dependencies: testDeps } ->
{ dependencies: fromMaybe (Dependencies Map.empty) testDeps
, execArgs: Nothing
, exec_args: Nothing
, main: moduleMain
, censor_test_warnings: censorTestWarnings
, strict
Expand Down
6 changes: 3 additions & 3 deletions src/Spago/Command/Run.purs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type RunEnv a =
}

type RunOptions =
{ execArgs :: Array String
{ exec_args :: Array String
, moduleName :: String
, sourceDir :: FilePath
, executeDir :: FilePath
Expand Down Expand Up @@ -80,7 +80,7 @@ run = do
packageJsonPath = Path.concat [ runDir, "package.json" ]
packageJsonContents = "{\"type\":\"module\" }"

nodeArgs = [ runJsPath ] <> opts.execArgs
nodeArgs = [ runJsPath ] <> opts.exec_args

nodeContents =
Array.fold
Expand Down Expand Up @@ -126,7 +126,7 @@ run = do
logDebug $ show err
die opts.failureMessage
Just backend -> do
let args = [ "--run", opts.moduleName <> ".main" ] <> opts.execArgs
let args = [ "--run", opts.moduleName <> ".main" ] <> opts.exec_args
logDebug $ "Running command `" <> backend.cmd <> " " <> show args <> "`"
Cmd.exec backend.cmd args execOptions >>= case _ of
Right _r -> case opts.successMessage of
Expand Down
6 changes: 3 additions & 3 deletions src/Spago/Command/Test.purs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type TestEnv a =
}

type SelectedTest =
{ execArgs :: Array String
{ exec_args :: Array String
, moduleName :: String
, selected :: WorkspacePackage
}

run :: forall a. Spago (TestEnv a) Unit
run = do
{ workspace, logOptions, node, selectedPackages, dependencies, purs } <- ask
void $ for selectedPackages \{ execArgs, moduleName, selected } -> do
void $ for selectedPackages \{ exec_args, moduleName, selected } -> do

let
name = selected.package.name
Expand All @@ -38,7 +38,7 @@ run = do
, failureMessage: "Tests failed for package \"" <> PackageName.print name <> "\"."
, executeDir: Paths.cwd
, sourceDir: Paths.cwd
, execArgs
, exec_args
, moduleName
}

Expand Down
2 changes: 1 addition & 1 deletion test/Spago/Build.purs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ spec = Spec.around withTempDir do
, strict: Nothing
, censor_test_warnings: Nothing
, dependencies: mkDependencies [ "newtype" ]
, execArgs: Nothing
, exec_args: Nothing
}
}
}
Expand Down

0 comments on commit 704baee

Please sign in to comment.