Skip to content

Commit 1f5382d

Browse files
lukekarryswraithgar
authored andcommitted
fix: don't set stdioString for any spawn/run-script calls
These libraries now return strings by default which is what we always want in the CLI for error reporting. Fixes #5766
1 parent abfb28b commit 1f5382d

File tree

14 files changed

+9
-40
lines changed

14 files changed

+9
-40
lines changed

lib/commands/ci.js

-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class CI extends ArboristWorkspaceCmd {
9494
args: [],
9595
scriptShell,
9696
stdio: 'inherit',
97-
stdioString: true,
9897
banner: !this.npm.silent,
9998
event,
10099
})

lib/commands/explore.js

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class Explore extends BaseCommand {
5959
pkg,
6060
banner: false,
6161
path,
62-
stdioString: true,
6362
event: '_explore',
6463
stdio: 'inherit',
6564
}).catch(er => {

lib/commands/install.js

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class Install extends ArboristWorkspaceCmd {
161161
args: [],
162162
scriptShell,
163163
stdio: 'inherit',
164-
stdioString: true,
165164
banner: !this.npm.silent,
166165
event,
167166
})

lib/commands/run-script.js

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class RunScript extends BaseCommand {
117117
args,
118118
scriptShell,
119119
stdio: 'inherit',
120-
stdioString: true,
121120
pkg,
122121
banner: !this.npm.silent,
123122
}

scripts/util.js

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const spawn = async (cmd, ...allArgs) => {
5555
let res = null
5656
try {
5757
const spawnOpts = {
58-
stdioString: true,
5958
stdio: quiet || out || lines ? 'pipe' : 'inherit',
6059
cwd: CWD,
6160
...opts,

smoke-tests/test/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ const exec = async (...args) => {
9595
PATH: `${PATH}:${binLocation}`,
9696
COMSPEC: process.env.COMSPEC,
9797
},
98-
stdioString: true,
9998
encoding: 'utf-8',
10099
})
101100

test/bin/windows-shims.js

-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ for (const [name, bash] of bashes) {
100100
const result = await spawn(bash, args, {
101101
env: { PATH: path, npm_config_update_notifier: 'false' },
102102
cwd: path,
103-
stdioString: true,
104103
})
105104
t.match(result, {
106105
cmd: bash,
@@ -119,7 +118,6 @@ for (const [name, bash] of bashes) {
119118
const result = await spawn(bash, args, {
120119
env: { PATH: path, npm_config_update_notifier: 'false' },
121120
cwd: path,
122-
stdioString: true,
123121
})
124122
t.match(result, {
125123
cmd: bash,

test/lib/commands/run-script.js

-9
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ t.test('default env, start, and restart scripts', t => {
125125
args: [],
126126
scriptShell: undefined,
127127
stdio: 'inherit',
128-
stdioString: true,
129128
pkg: { name: 'x', version: '1.2.3', _id: 'x@1.2.3', scripts: {} },
130129
event: 'start',
131130
},
@@ -140,7 +139,6 @@ t.test('default env, start, and restart scripts', t => {
140139
args: [],
141140
scriptShell: undefined,
142141
stdio: 'inherit',
143-
stdioString: true,
144142
pkg: {
145143
name: 'x',
146144
version: '1.2.3',
@@ -162,7 +160,6 @@ t.test('default env, start, and restart scripts', t => {
162160
args: [],
163161
scriptShell: undefined,
164162
stdio: 'inherit',
165-
stdioString: true,
166163
pkg: {
167164
name: 'x',
168165
version: '1.2.3',
@@ -185,7 +182,6 @@ t.test('default env, start, and restart scripts', t => {
185182
args: [],
186183
scriptShell: undefined,
187184
stdio: 'inherit',
188-
stdioString: true,
189185
pkg: {
190186
name: 'x',
191187
version: '1.2.3',
@@ -220,7 +216,6 @@ t.test('non-default env script', t => {
220216
args: [],
221217
scriptShell: undefined,
222218
stdio: 'inherit',
223-
stdioString: true,
224219
pkg: {
225220
name: 'x',
226221
version: '1.2.3',
@@ -242,7 +237,6 @@ t.test('non-default env script', t => {
242237
args: [],
243238
scriptShell: undefined,
244239
stdio: 'inherit',
245-
stdioString: true,
246240
pkg: {
247241
name: 'x',
248242
version: '1.2.3',
@@ -305,7 +299,6 @@ t.test('run pre/post hooks', async t => {
305299
args: [],
306300
scriptShell: undefined,
307301
stdio: 'inherit',
308-
stdioString: true,
309302
pkg: {
310303
name: 'x',
311304
version: '1.2.3',
@@ -342,7 +335,6 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => {
342335
args: [],
343336
scriptShell: undefined,
344337
stdio: 'inherit',
345-
stdioString: true,
346338
pkg: {
347339
name: 'x',
348340
version: '1.2.3',
@@ -385,7 +377,6 @@ t.test('run silent', async t => {
385377
args: [],
386378
scriptShell: undefined,
387379
stdio: 'inherit',
388-
stdioString: true,
389380
pkg: {
390381
name: 'x',
391382
version: '1.2.3',

workspaces/arborist/lib/arborist/rebuild.js

-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ module.exports = cls => class Builder extends cls {
345345
event,
346346
path,
347347
pkg,
348-
stdioString: true,
349348
stdio,
350349
env,
351350
scriptShell: this[_scriptShell],

workspaces/arborist/lib/arborist/reify.js

-1
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,6 @@ module.exports = cls => class Reifier extends cls {
15581558
event,
15591559
path,
15601560
pkg,
1561-
stdioString: true,
15621561
stdio,
15631562
scriptShell: this.options.scriptShell,
15641563
})

workspaces/arborist/test/arborist/rebuild.js

-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ t.test('rebuild node-gyp dependencies lacking both preinstall and install script
421421
event: 'install',
422422
path: resolve(path, 'node_modules/dep'),
423423
pkg: { scripts: { install: 'node-gyp rebuild' } },
424-
stdioString: true,
425424
env: {
426425
npm_package_resolved: null,
427426
npm_package_integrity: null,

workspaces/arborist/test/arborist/reify.js

-1
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,6 @@ console.log('ok 1 - this is fine')
17701770
event: 'test',
17711771
path,
17721772
pkg,
1773-
stdioString: true,
17741773
stdio: 'pipe',
17751774
}), 'test result')
17761775
})

workspaces/libnpmexec/lib/run-script.js

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const run = async ({
6868
banner: false,
6969
// we always run in cwd, not --prefix
7070
path: runPath,
71-
stdioString: true,
7271
binPaths,
7372
event: 'npx',
7473
args,

workspaces/libnpmpack/test/index.js

+9-18
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ const OPTS = {
1616

1717
const REG = OPTS.registry
1818

19-
// TODO this ... smells. npm "script-shell" config mentions defaults but those
20-
// are handled by run-script, not npm. So for now we have to tie tests to some
21-
// pretty specific internals of runScript
22-
const makeSpawnArgs = require('@npmcli/run-script/lib/make-spawn-args.js')
23-
2419
t.test('packs from local directory', async t => {
2520
const testDir = t.testdir({
2621
'package.json': JSON.stringify({
@@ -152,13 +147,15 @@ t.test('runs scripts in foreground when foregroundScripts === true', async t =>
152147
const cwd = process.cwd()
153148
process.chdir(testDir)
154149

155-
const [scriptShell, scriptArgs] = makeSpawnArgs({
156-
event: 'prepack',
157-
path: testDir,
158-
cmd: 'touch prepack',
159-
})
150+
const shell = process.platform === 'win32'
151+
? process.env.COMSPEC
152+
: 'sh'
153+
154+
const args = process.platform === 'win32'
155+
? ['/d', '/s', '/c', 'touch prepack']
156+
: ['-c', 'touch prepack']
160157

161-
const prepack = spawk.spawn(scriptShell, scriptArgs)
158+
const prepack = spawk.spawn(shell, args)
162159

163160
await pack('file:.', {
164161
packDestination: testDir,
@@ -186,13 +183,7 @@ t.test('doesn\'t run scripts when ignoreScripts === true', async t => {
186183
const cwd = process.cwd()
187184
process.chdir(testDir)
188185

189-
const [scriptShell, scriptArgs] = makeSpawnArgs({
190-
event: 'prepack',
191-
path: testDir,
192-
cmd: 'touch prepack',
193-
})
194-
195-
const prepack = spawk.spawn(scriptShell, scriptArgs)
186+
const prepack = spawk.spawn('sh', ['-c', 'touch prepack'])
196187

197188
await pack('file:.', {
198189
packDestination: testDir,

0 commit comments

Comments
 (0)