Skip to content

Commit 6d5929a

Browse files
JordanMartinezf-f
andauthored
Make workspace output dir absolute path (#1119)
--------- Co-authored-by: Fabrizio Ferrai <[email protected]>
1 parent 47b735c commit 6d5929a

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

bin/src/Main.purs

-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,6 @@ mkRunEnv runArgs { dependencies, purs } = do
764764
runOptions =
765765
{ moduleName
766766
, execArgs
767-
, sourceDir: Paths.cwd
768767
, executeDir: Paths.cwd
769768
, successMessage: Nothing
770769
, failureMessage: "Running failed."

src/Spago/Command/Run.purs

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type RunEnv a =
3838
type RunOptions =
3939
{ execArgs :: Array String
4040
, moduleName :: String
41-
, sourceDir :: FilePath
4241
, executeDir :: FilePath
4342
, successMessage :: Maybe String
4443
, failureMessage :: String
@@ -75,6 +74,7 @@ run = do
7574
logDebug "Running with backend: nodejs"
7675
let runDir = Path.concat [ Paths.localCachePath, "run" ]
7776
FS.mkdirp runDir
77+
absOutput <- liftEffect $ Path.resolve [] $ fromMaybe "output" workspace.buildOptions.output
7878
let
7979
runJsPath = Path.concat [ runDir, "run.js" ]
8080
packageJsonPath = Path.concat [ runDir, "package.json" ]
@@ -85,9 +85,7 @@ run = do
8585
nodeContents =
8686
Array.fold
8787
[ "import { main } from 'file://"
88-
, withForwardSlashes opts.sourceDir
89-
, "/"
90-
, fromMaybe "output" workspace.buildOptions.output
88+
, withForwardSlashes absOutput
9189
, "/"
9290
, opts.moduleName
9391
, "/"

src/Spago/Command/Test.purs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ run = do
3737
{ successMessage: Just $ "Test succeeded for package \"" <> PackageName.print name <> "\"."
3838
, failureMessage: "Tests failed for package \"" <> PackageName.print name <> "\"."
3939
, executeDir: Paths.cwd
40-
, sourceDir: Paths.cwd
4140
, execArgs
4241
, moduleName
4342
}

test/Spago/Test.purs

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Spago.Command.Init (DefaultConfigOptions(..))
1212
import Spago.Command.Init as Init
1313
import Spago.Core.Config as Config
1414
import Spago.FS as FS
15+
import Spago.Paths (paths)
1516
import Test.Spec (Spec)
1617
import Test.Spec as Spec
1718
import Test.Spec.Assertions as Assert
@@ -25,6 +26,13 @@ spec = Spec.around withTempDir do
2526
spago [ "build" ] >>= shouldBeSuccess
2627
spago [ "test" ] >>= shouldBeSuccessOutputWithErr (fixture "test-output-stdout.txt") (fixture "test-output-stderr.txt")
2728

29+
Spec.it "tests successfully when using a different output dir" \{ spago, fixture } -> do
30+
spago [ "init", "--name", "7368613235362d6a336156536c675a7033334e7659556c6d38" ] >>= shouldBeSuccess
31+
32+
let tempDir = Path.concat [ paths.temp, "output" ]
33+
spago [ "build", "--output", tempDir ] >>= shouldBeSuccess
34+
spago [ "test", "--output", tempDir ] >>= shouldBeSuccessOutputWithErr (fixture "test-output-stdout.txt") (fixture "test-output-stderr.txt")
35+
2836
Spec.it "fails nicely when the test module is not found" \{ spago, fixture } -> do
2937
spago [ "init", "--name", "7368613235362d6a336156536c675a7033334e7659556c6d38" ] >>= shouldBeSuccess
3038
spago [ "build" ] >>= shouldBeSuccess

0 commit comments

Comments
 (0)