From 793466e88f8c9608069c893f2928198d2fbe53b3 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Sun, 30 Jan 2022 09:41:58 +0000 Subject: [PATCH 1/7] Remove run.js --- src/Spago/Build.hs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Spago/Build.hs b/src/Spago/Build.hs index 68b37a858..e13a7ea00 100644 --- a/src/Spago/Build.hs +++ b/src/Spago/Build.hs @@ -330,12 +330,10 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe build (Just postBuild) where fromFilePath = Text.pack . Turtle.encodeString - runJsSource = fromFilePath (sourceDir Turtle. ".spago/run.js") nodeArgs = Text.intercalate " " $ map unBackendArg extraArgs nodeContents outputPath' = fold - [ "#!/usr/bin/env node\n\n" - , "require('" + [ "require('" , Text.replace "\\" "/" (fromFilePath sourceDir) , "/" , Text.pack outputPath' @@ -343,16 +341,10 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe , unModuleName moduleName , "').main()" ] - nodeCmd = "node " <> runJsSource <> " " <> nodeArgs + nodeCmd outputPath'= "node -e \"" <> nodeContents outputPath' <> "\" " <> nodeArgs nodeAction outputPath' = do - logDebug $ "Writing " <> displayShow @Text runJsSource - writeTextFile runJsSource (nodeContents outputPath') - void $ chmod executable $ pathFromText runJsSource - -- cd to executeDir in case it isn't the same as sourceDir - logDebug $ "Executing from: " <> displayShow @FilePath executeDir - Turtle.cd executeDir -- We build a process by hand here because we need to forward the stdin to the backend process - let processWithStdin = (Process.shell (Text.unpack nodeCmd)) { Process.std_in = Process.Inherit } + let processWithStdin = (Process.shell (Text.unpack $ nodeCmd outputPath')) { Process.std_in = Process.Inherit } Turtle.system processWithStdin empty >>= \case ExitSuccess -> maybe (pure ()) (logInfo . display) maybeSuccessMessage ExitFailure n -> die [ display failureMessage <> "exit code: " <> repr n ] From 3eaf5d40a8d5fd307680696161a90cd7c4a9a3fd Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Sun, 30 Jan 2022 09:46:08 +0000 Subject: [PATCH 2/7] Update CHANGELOG. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b417d00ce..82111368c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +Other improvements: +- Remove run.js in preparation of `v0.15.0` release (#845) + ## [0.20.4] - 2022-01-29 Bugfixes: From 15ea947459c3a038004aabdd3c472b5b591b6c73 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Sun, 30 Jan 2022 11:00:16 +0000 Subject: [PATCH 3/7] Undo remove executeDir --- src/Spago/Build.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Spago/Build.hs b/src/Spago/Build.hs index e13a7ea00..c01e81715 100644 --- a/src/Spago/Build.hs +++ b/src/Spago/Build.hs @@ -343,6 +343,9 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe ] nodeCmd outputPath'= "node -e \"" <> nodeContents outputPath' <> "\" " <> nodeArgs nodeAction outputPath' = do + -- cd to executeDir in case it isn't the same as sourceDir + logDebug $ "Executing from: " <> displayShow @FilePath executeDir + Turtle.cd executeDir -- We build a process by hand here because we need to forward the stdin to the backend process let processWithStdin = (Process.shell (Text.unpack $ nodeCmd outputPath')) { Process.std_in = Process.Inherit } Turtle.system processWithStdin empty >>= \case From b8e4c8d48d5532d71f3d23135a5027f44f8e6a86 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Sun, 30 Jan 2022 12:50:04 +0000 Subject: [PATCH 4/7] Fix failing test --- test/fixtures/spago-run-args.purs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/spago-run-args.purs b/test/fixtures/spago-run-args.purs index 447a70bc6..aaa57155b 100644 --- a/test/fixtures/spago-run-args.purs +++ b/test/fixtures/spago-run-args.purs @@ -10,5 +10,5 @@ import Data.Show (show) main :: Effect Unit main = do args <- argv - -- dropping the first two args, node path and script name, to make test stable - log $ show $ drop 2 args + -- dropping the first arg, node path to make test stable + log $ show $ drop 1 args From 1c076c035d5db88f5b744692339deb675e6d3d54 Mon Sep 17 00:00:00 2001 From: sigma-andex <77549848+sigma-andex@users.noreply.github.com> Date: Sun, 30 Jan 2022 15:23:31 +0000 Subject: [PATCH 5/7] Update CHANGELOG.md Co-authored-by: Fabrizio Ferrai --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82111368c..8429fd448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] Other improvements: -- Remove run.js in preparation of `v0.15.0` release (#845) +- Avoid writing a JS file when executing `spago run` (#845, #846) ## [0.20.4] - 2022-01-29 From 19091731e3099f1f635785c59b302c453b5bfd22 Mon Sep 17 00:00:00 2001 From: sigma-andex <77549848+sigma-andex@users.noreply.github.com> Date: Sun, 30 Jan 2022 15:23:55 +0000 Subject: [PATCH 6/7] Update src/Spago/Build.hs Co-authored-by: Fabrizio Ferrai --- src/Spago/Build.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Spago/Build.hs b/src/Spago/Build.hs index c01e81715..edfbb33d4 100644 --- a/src/Spago/Build.hs +++ b/src/Spago/Build.hs @@ -347,6 +347,7 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe logDebug $ "Executing from: " <> displayShow @FilePath executeDir Turtle.cd executeDir -- We build a process by hand here because we need to forward the stdin to the backend process + logDebug $ "Running node command: `" <> nodeCmd outputPath' <> "`" let processWithStdin = (Process.shell (Text.unpack $ nodeCmd outputPath')) { Process.std_in = Process.Inherit } Turtle.system processWithStdin empty >>= \case ExitSuccess -> maybe (pure ()) (logInfo . display) maybeSuccessMessage From 740d7e89a95e19befc1e656334209ff057acf256 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Sun, 30 Jan 2022 15:31:23 +0000 Subject: [PATCH 7/7] Fix missing display --- src/Spago/Build.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spago/Build.hs b/src/Spago/Build.hs index edfbb33d4..597d1e621 100644 --- a/src/Spago/Build.hs +++ b/src/Spago/Build.hs @@ -347,7 +347,7 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe logDebug $ "Executing from: " <> displayShow @FilePath executeDir Turtle.cd executeDir -- We build a process by hand here because we need to forward the stdin to the backend process - logDebug $ "Running node command: `" <> nodeCmd outputPath' <> "`" + logDebug $ "Running node command: `" <> (display $ nodeCmd outputPath') <> "`" let processWithStdin = (Process.shell (Text.unpack $ nodeCmd outputPath')) { Process.std_in = Process.Inherit } Turtle.system processWithStdin empty >>= \case ExitSuccess -> maybe (pure ()) (logInfo . display) maybeSuccessMessage