fix: move run-script banners to stderr when in json mode#7439
fix: move run-script banners to stderr when in json mode#7439lukekarrys merged 3 commits intolatestfrom
Conversation
Closes #7425
|
|
||
| run(paths) | ||
| .then((res) => console.log(`Wrote ${res.length} files`)) | ||
| .then((res) => console.error(`Wrote ${res.length} files`)) |
There was a problem hiding this comment.
This change was made so that our prepack script doesn't log anything to stdout, so that a smoke-test could be added that running node . pack --json only ends up with json parseable output on stdout.
This highlights an important note about this change, as it only redirects the banner from @npmcli/run-script to stderr when --json is set. The user's run-script is spawned with stdio: inherit so if that process sends output to stdout it could still break in json mode. This is not something npm should change since we want to allow spawned process to write to whatever stream they want.
If a user really wants to ensure that the script cannot output anything, they should also use --foreground-scripts=false or --silent.
e6317ad to
0ced0b7
Compare
Fixes #7354