Skip to content

Commit 34ecf46

Browse files
committed
feat!: dont set a default for stdioString
BREAKING CHANGE: `stdioString` is no longer set to `false` by default. Instead it is not set and passed directory to `@npmcli/promise-spawn` which defaults it to `true`.
1 parent 1eef610 commit 34ecf46

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ runScript({
3030
// optional, defaults to /bin/sh on unix, or cmd.exe on windows
3131
scriptShell: '/bin/bash',
3232

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

3737
// optional, additional environment variables to add
3838
// note that process.env IS inherited by default
@@ -121,8 +121,9 @@ terminal, then it is up to the user to end it, of course.
121121
the result/error object.
122122
- `cmd` Optional. Override the script from the `package.json` with
123123
something else, which will be run in an otherwise matching environment.
124-
- `stdioString` Optional, defaults to `false`. Return string values for
125-
`stderr` and `stdout` rather than Buffers.
124+
- `stdioString` Optional, passed directly to `@npmcli/promise-spawn` which
125+
defaults it to `true`. Return string values for `stderr` and `stdout` rather
126+
than Buffers.
126127
- `banner` Optional, defaults to `true`. If the `stdio` option is set to
127128
`'inherit'`, then print a banner with the package name and version, event
128129
name, and script command to be run. Set explicitly to `false` to disable

lib/make-spawn-args.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const makeSpawnArgs = options => {
1313
stdio,
1414
cmd,
1515
args = [],
16-
stdioString = false,
16+
stdioString,
1717
} = options
1818

1919
const spawnEnv = setPATH(path, binPaths, {

lib/run-script-pkg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const runScriptPkg = async options => {
2828
stdio = 'pipe',
2929
pkg,
3030
args = [],
31-
stdioString = false,
31+
stdioString,
3232
// note: only used when stdio:inherit
3333
banner = true,
3434
// how long to wait for a process.kill signal

test/run-script-pkg.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ t.test('pkg has server.js, start not specified', async t => {
5555
},
5656
})
5757
t.strictSame(res, ['sh', ['-c', 'node server.js'], {
58-
stdioString: false,
58+
stdioString: undefined,
5959
event: 'start',
6060
path,
6161
scriptShell: 'sh',
@@ -92,7 +92,7 @@ t.test('pkg has server.js, start not specified, with args', async t => {
9292
},
9393
})
9494
t.strictSame(res, ['sh', ['-c', 'node server.js'], {
95-
stdioString: false,
95+
stdioString: undefined,
9696
event: 'start',
9797
path,
9898
scriptShell: 'sh',
@@ -130,7 +130,7 @@ t.test('pkg has no foo script, but custom cmd provided', t => runScriptPkg({
130130
scripts: {},
131131
},
132132
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
133-
stdioString: false,
133+
stdioString: undefined,
134134
event: 'foo',
135135
path: 'path',
136136
scriptShell: 'sh',
@@ -167,7 +167,7 @@ t.test('do the banner when stdio is inherited, handle line breaks', t => {
167167
scripts: {},
168168
},
169169
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar\nbaz\n'], {
170-
stdioString: false,
170+
stdioString: undefined,
171171
event: 'foo',
172172
path: 'path',
173173
scriptShell: 'sh',
@@ -206,7 +206,7 @@ t.test('do not show banner when stdio is inherited, if suppressed', t => {
206206
},
207207
banner: false,
208208
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
209-
stdioString: false,
209+
stdioString: undefined,
210210
event: 'foo',
211211
path: 'path',
212212
scriptShell: 'sh',
@@ -244,7 +244,7 @@ t.test('do the banner with no pkgid', t => {
244244
scripts: {},
245245
},
246246
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
247-
stdioString: false,
247+
stdioString: undefined,
248248
event: 'foo',
249249
path: 'path',
250250
scriptShell: 'sh',
@@ -278,7 +278,7 @@ t.test('pkg has foo script', t => runScriptPkg({
278278
},
279279
},
280280
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
281-
stdioString: false,
281+
stdioString: undefined,
282282
event: 'foo',
283283
path: 'path',
284284
scriptShell: 'sh',
@@ -313,7 +313,7 @@ t.test('pkg has foo script, with args', t => runScriptPkg({
313313
args: ['a', 'b', 'c'],
314314
binPaths: false,
315315
}).then(res => t.strictSame(res, ['sh', ['-c', 'bar'], {
316-
stdioString: false,
316+
stdioString: undefined,
317317
event: 'foo',
318318
path: 'path',
319319
scriptShell: 'sh',
@@ -361,7 +361,7 @@ t.test('pkg has no install or preinstall script, but node-gyp files are present'
361361
env: { environ: 'value' },
362362
stdio: 'pipe',
363363
cmd: 'node-gyp rebuild',
364-
stdioString: false,
364+
stdioString: undefined,
365365
},
366366
{
367367
event: 'install',
@@ -422,7 +422,7 @@ t.test('end stdin if present', async t => {
422422
env: {},
423423
stdio: 'pipe',
424424
cmd: 'cat',
425-
stdioString: false,
425+
stdioString: undefined,
426426
}, {
427427
event: 'cat',
428428
script: 'cat',

0 commit comments

Comments
 (0)