Skip to content

feat!: dont set a default for stdioString #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ runScript({
// optional, defaults to /bin/sh on unix, or cmd.exe on windows
scriptShell: '/bin/bash',

// optional, defaults to false
// optional, passed directly to `@npmcli/promise-spawn` which defaults it to true
// return stdout and stderr as strings rather than buffers
stdioString: true,
stdioString: false,

// optional, additional environment variables to add
// note that process.env IS inherited by default
Expand Down Expand Up @@ -121,8 +121,9 @@ terminal, then it is up to the user to end it, of course.
the result/error object.
- `cmd` Optional. Override the script from the `package.json` with
something else, which will be run in an otherwise matching environment.
- `stdioString` Optional, defaults to `false`. Return string values for
`stderr` and `stdout` rather than Buffers.
- `stdioString` Optional, passed directly to `@npmcli/promise-spawn` which
defaults it to `true`. Return string values for `stderr` and `stdout` rather
than Buffers.
- `banner` Optional, defaults to `true`. If the `stdio` option is set to
`'inherit'`, then print a banner with the package name and version, event
name, and script command to be run. Set explicitly to `false` to disable
Expand Down
2 changes: 1 addition & 1 deletion lib/make-spawn-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const makeSpawnArgs = options => {
stdio,
cmd,
args = [],
stdioString = false,
stdioString,
} = options

const spawnEnv = setPATH(path, binPaths, {
Expand Down
2 changes: 1 addition & 1 deletion lib/run-script-pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const runScriptPkg = async options => {
stdio = 'pipe',
pkg,
args = [],
stdioString = false,
stdioString,
// note: only used when stdio:inherit
banner = true,
// how long to wait for a process.kill signal
Expand Down
20 changes: 10 additions & 10 deletions test/run-script-pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ t.test('pkg has server.js, start not specified', async t => {
},
})
t.strictSame(res, ['sh', ['-c', 'node server.js'], {
stdioString: false,
stdioString: undefined,
event: 'start',
path,
scriptShell: 'sh',
Expand Down Expand Up @@ -92,7 +92,7 @@ t.test('pkg has server.js, start not specified, with args', async t => {
},
})
t.strictSame(res, ['sh', ['-c', 'node server.js'], {
stdioString: false,
stdioString: undefined,
event: 'start',
path,
scriptShell: 'sh',
Expand Down Expand Up @@ -130,7 +130,7 @@ t.test('pkg has no foo script, but custom cmd provided', t => runScriptPkg({
scripts: {},
},
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -167,7 +167,7 @@ t.test('do the banner when stdio is inherited, handle line breaks', t => {
scripts: {},
},
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar\nbaz\n'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -206,7 +206,7 @@ t.test('do not show banner when stdio is inherited, if suppressed', t => {
},
banner: false,
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -244,7 +244,7 @@ t.test('do the banner with no pkgid', t => {
scripts: {},
},
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -278,7 +278,7 @@ t.test('pkg has foo script', t => runScriptPkg({
},
},
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -313,7 +313,7 @@ t.test('pkg has foo script, with args', t => runScriptPkg({
args: ['a', 'b', 'c'],
binPaths: false,
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
stdioString: false,
stdioString: undefined,
event: 'foo',
path: 'path',
scriptShell: 'sh',
Expand Down Expand Up @@ -361,7 +361,7 @@ t.test('pkg has no install or preinstall script, but node-gyp files are present'
env: { environ: 'value' },
stdio: 'pipe',
cmd: 'node-gyp rebuild',
stdioString: false,
stdioString: undefined,
},
{
event: 'install',
Expand Down Expand Up @@ -422,7 +422,7 @@ t.test('end stdin if present', async t => {
env: {},
stdio: 'pipe',
cmd: 'cat',
stdioString: false,
stdioString: undefined,
}, {
event: 'cat',
script: 'cat',
Expand Down