@@ -330,29 +330,25 @@ runBackend maybeBackend RunDirectories{ sourceDir, executeDir } moduleName maybe
330
330
build (Just postBuild)
331
331
where
332
332
fromFilePath = Text. pack . Turtle. encodeString
333
- runJsSource = fromFilePath (sourceDir Turtle. </> " .spago/run.js" )
334
333
nodeArgs = Text. intercalate " " $ map unBackendArg extraArgs
335
334
nodeContents outputPath' =
336
335
fold
337
- [ " #!/usr/bin/env node\n\n "
338
- , " require('"
336
+ [ " require('"
339
337
, Text. replace " \\ " " /" (fromFilePath sourceDir)
340
338
, " /"
341
339
, Text. pack outputPath'
342
340
, " /"
343
341
, unModuleName moduleName
344
342
, " ').main()"
345
343
]
346
- nodeCmd = " node " <> runJsSource <> " " <> nodeArgs
344
+ nodeCmd outputPath' = " node -e \" " <> nodeContents outputPath' <> " \ " " <> nodeArgs
347
345
nodeAction outputPath' = do
348
- logDebug $ " Writing " <> displayShow @ Text runJsSource
349
- writeTextFile runJsSource (nodeContents outputPath')
350
- void $ chmod executable $ pathFromText runJsSource
351
346
-- cd to executeDir in case it isn't the same as sourceDir
352
347
logDebug $ " Executing from: " <> displayShow @ FilePath executeDir
353
348
Turtle. cd executeDir
354
349
-- We build a process by hand here because we need to forward the stdin to the backend process
355
- let processWithStdin = (Process. shell (Text. unpack nodeCmd)) { Process. std_in = Process. Inherit }
350
+ logDebug $ " Running node command: `" <> (display $ nodeCmd outputPath') <> " `"
351
+ let processWithStdin = (Process. shell (Text. unpack $ nodeCmd outputPath')) { Process. std_in = Process. Inherit }
356
352
Turtle. system processWithStdin empty >>= \ case
357
353
ExitSuccess -> maybe (pure () ) (logInfo . display) maybeSuccessMessage
358
354
ExitFailure n -> die [ display failureMessage <> " exit code: " <> repr n ]
0 commit comments