mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-10-05 13:17:36 +03:00
Fix issue where command output did not pipe through correctly in the middle of a Stream.
This commit is contained in:
parent
f9f066eece
commit
e837c9538f
@ -100,6 +100,23 @@ b =
|
||||
2
|
||||
"""
|
||||
)
|
||||
, Stream.fromString "module A\na=0"
|
||||
|> Stream.pipe (Stream.command "elm-format" [ "--stdin" ])
|
||||
|> Stream.pipe (Stream.fileWrite "formatted-elm.txt")
|
||||
|> Stream.run
|
||||
|> BackendTask.quiet
|
||||
|> BackendTask.andThen
|
||||
(\() ->
|
||||
Stream.fileRead "formatted-elm.txt"
|
||||
|> Stream.read
|
||||
|> try
|
||||
)
|
||||
|> test "write to file"
|
||||
(\{ metadata, body } ->
|
||||
body
|
||||
|> Expect.equal
|
||||
"module A exposing (a)\n\n\na =\n 0\n"
|
||||
)
|
||||
, Stream.fileRead "elm.json"
|
||||
|> Stream.pipe
|
||||
(Stream.command "jq"
|
||||
|
@ -798,12 +798,17 @@ function runStream(req, portsFile, context) {
|
||||
const { command, args, allowNon0Status, output } = part;
|
||||
/** @type {'ignore' | 'inherit'} } */
|
||||
let letPrint = quiet ? "ignore" : "inherit";
|
||||
let stderrKind = kind === "none" ? letPrint : "pipe";
|
||||
let stderrKind = kind === "none" && isLastProcess ? letPrint : "pipe";
|
||||
if (output === "Ignore") {
|
||||
stderrKind = "ignore";
|
||||
} else if (output === "Print") {
|
||||
stderrKind = letPrint;
|
||||
}
|
||||
|
||||
const stdoutKind =
|
||||
(output === "InsteadOfStdout" || kind === "none") && isLastProcess
|
||||
? letPrint
|
||||
: "pipe";
|
||||
/**
|
||||
* @type {import('node:child_process').ChildProcess}
|
||||
*/
|
||||
@ -811,9 +816,7 @@ function runStream(req, portsFile, context) {
|
||||
stdio: [
|
||||
"pipe",
|
||||
// if we are capturing stderr instead of stdout, print out stdout with `inherit`
|
||||
output === "InsteadOfStdout" || kind === "none"
|
||||
? letPrint
|
||||
: "pipe",
|
||||
stdoutKind,
|
||||
stderrKind,
|
||||
],
|
||||
cwd: cwd,
|
||||
|
Loading…
Reference in New Issue
Block a user