Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2022-11-02 03:43:39 +0300
committerGar <wraithgar@github.com>2022-11-02 20:08:27 +0300
commit1f5382dada181cda41f1504974de1e69a6c1ad7f (patch)
tree7f22477b4f43d3e8905c22334793f1f3bd892fa6
parentabfb28b249183b8c033f8e7acc1546150cdac137 (diff)
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
-rw-r--r--lib/commands/ci.js1
-rw-r--r--lib/commands/explore.js1
-rw-r--r--lib/commands/install.js1
-rw-r--r--lib/commands/run-script.js1
-rw-r--r--scripts/util.js1
-rw-r--r--smoke-tests/test/index.js1
-rw-r--r--test/bin/windows-shims.js2
-rw-r--r--test/lib/commands/run-script.js9
-rw-r--r--workspaces/arborist/lib/arborist/rebuild.js1
-rw-r--r--workspaces/arborist/lib/arborist/reify.js1
-rw-r--r--workspaces/arborist/test/arborist/rebuild.js1
-rw-r--r--workspaces/arborist/test/arborist/reify.js1
-rw-r--r--workspaces/libnpmexec/lib/run-script.js1
-rw-r--r--workspaces/libnpmpack/test/index.js27
14 files changed, 9 insertions, 40 deletions
diff --git a/lib/commands/ci.js b/lib/commands/ci.js
index 0adf203a9..38ee1426d 100644
--- a/lib/commands/ci.js
+++ b/lib/commands/ci.js
@@ -94,7 +94,6 @@ class CI extends ArboristWorkspaceCmd {
args: [],
scriptShell,
stdio: 'inherit',
- stdioString: true,
banner: !this.npm.silent,
event,
})
diff --git a/lib/commands/explore.js b/lib/commands/explore.js
index 5b97673b9..0d915cb4c 100644
--- a/lib/commands/explore.js
+++ b/lib/commands/explore.js
@@ -59,7 +59,6 @@ class Explore extends BaseCommand {
pkg,
banner: false,
path,
- stdioString: true,
event: '_explore',
stdio: 'inherit',
}).catch(er => {
diff --git a/lib/commands/install.js b/lib/commands/install.js
index 512226c6b..246d7fdf8 100644
--- a/lib/commands/install.js
+++ b/lib/commands/install.js
@@ -161,7 +161,6 @@ class Install extends ArboristWorkspaceCmd {
args: [],
scriptShell,
stdio: 'inherit',
- stdioString: true,
banner: !this.npm.silent,
event,
})
diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js
index 8507dbe79..3852f7ba1 100644
--- a/lib/commands/run-script.js
+++ b/lib/commands/run-script.js
@@ -117,7 +117,6 @@ class RunScript extends BaseCommand {
args,
scriptShell,
stdio: 'inherit',
- stdioString: true,
pkg,
banner: !this.npm.silent,
}
diff --git a/scripts/util.js b/scripts/util.js
index 91611bcf9..7e74eee3f 100644
--- a/scripts/util.js
+++ b/scripts/util.js
@@ -55,7 +55,6 @@ const spawn = async (cmd, ...allArgs) => {
let res = null
try {
const spawnOpts = {
- stdioString: true,
stdio: quiet || out || lines ? 'pipe' : 'inherit',
cwd: CWD,
...opts,
diff --git a/smoke-tests/test/index.js b/smoke-tests/test/index.js
index 7c196cb97..65a0363f2 100644
--- a/smoke-tests/test/index.js
+++ b/smoke-tests/test/index.js
@@ -95,7 +95,6 @@ const exec = async (...args) => {
PATH: `${PATH}:${binLocation}`,
COMSPEC: process.env.COMSPEC,
},
- stdioString: true,
encoding: 'utf-8',
})
diff --git a/test/bin/windows-shims.js b/test/bin/windows-shims.js
index 8d08e603b..e06e41bf8 100644
--- a/test/bin/windows-shims.js
+++ b/test/bin/windows-shims.js
@@ -100,7 +100,6 @@ for (const [name, bash] of bashes) {
const result = await spawn(bash, args, {
env: { PATH: path, npm_config_update_notifier: 'false' },
cwd: path,
- stdioString: true,
})
t.match(result, {
cmd: bash,
@@ -119,7 +118,6 @@ for (const [name, bash] of bashes) {
const result = await spawn(bash, args, {
env: { PATH: path, npm_config_update_notifier: 'false' },
cwd: path,
- stdioString: true,
})
t.match(result, {
cmd: bash,
diff --git a/test/lib/commands/run-script.js b/test/lib/commands/run-script.js
index 440c8dbad..8aafebcaf 100644
--- a/test/lib/commands/run-script.js
+++ b/test/lib/commands/run-script.js
@@ -125,7 +125,6 @@ t.test('default env, start, and restart scripts', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: { name: 'x', version: '1.2.3', _id: 'x@1.2.3', scripts: {} },
event: 'start',
},
@@ -140,7 +139,6 @@ t.test('default env, start, and restart scripts', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -162,7 +160,6 @@ t.test('default env, start, and restart scripts', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -185,7 +182,6 @@ t.test('default env, start, and restart scripts', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -220,7 +216,6 @@ t.test('non-default env script', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -242,7 +237,6 @@ t.test('non-default env script', t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -305,7 +299,6 @@ t.test('run pre/post hooks', async t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -342,7 +335,6 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
@@ -385,7 +377,6 @@ t.test('run silent', async t => {
args: [],
scriptShell: undefined,
stdio: 'inherit',
- stdioString: true,
pkg: {
name: 'x',
version: '1.2.3',
diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js
index 7e97984c0..6a675320d 100644
--- a/workspaces/arborist/lib/arborist/rebuild.js
+++ b/workspaces/arborist/lib/arborist/rebuild.js
@@ -345,7 +345,6 @@ module.exports = cls => class Builder extends cls {
event,
path,
pkg,
- stdioString: true,
stdio,
env,
scriptShell: this[_scriptShell],
diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js
index 08b38d002..c3cbf02b3 100644
--- a/workspaces/arborist/lib/arborist/reify.js
+++ b/workspaces/arborist/lib/arborist/reify.js
@@ -1558,7 +1558,6 @@ module.exports = cls => class Reifier extends cls {
event,
path,
pkg,
- stdioString: true,
stdio,
scriptShell: this.options.scriptShell,
})
diff --git a/workspaces/arborist/test/arborist/rebuild.js b/workspaces/arborist/test/arborist/rebuild.js
index ba31c5a20..df383c6ce 100644
--- a/workspaces/arborist/test/arborist/rebuild.js
+++ b/workspaces/arborist/test/arborist/rebuild.js
@@ -421,7 +421,6 @@ t.test('rebuild node-gyp dependencies lacking both preinstall and install script
event: 'install',
path: resolve(path, 'node_modules/dep'),
pkg: { scripts: { install: 'node-gyp rebuild' } },
- stdioString: true,
env: {
npm_package_resolved: null,
npm_package_integrity: null,
diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js
index ea7c3f0c6..257fcb4cb 100644
--- a/workspaces/arborist/test/arborist/reify.js
+++ b/workspaces/arborist/test/arborist/reify.js
@@ -1770,7 +1770,6 @@ console.log('ok 1 - this is fine')
event: 'test',
path,
pkg,
- stdioString: true,
stdio: 'pipe',
}), 'test result')
})
diff --git a/workspaces/libnpmexec/lib/run-script.js b/workspaces/libnpmexec/lib/run-script.js
index cee8ba45a..b34895c82 100644
--- a/workspaces/libnpmexec/lib/run-script.js
+++ b/workspaces/libnpmexec/lib/run-script.js
@@ -68,7 +68,6 @@ const run = async ({
banner: false,
// we always run in cwd, not --prefix
path: runPath,
- stdioString: true,
binPaths,
event: 'npx',
args,
diff --git a/workspaces/libnpmpack/test/index.js b/workspaces/libnpmpack/test/index.js
index aa4f955fa..ee34cd2c9 100644
--- a/workspaces/libnpmpack/test/index.js
+++ b/workspaces/libnpmpack/test/index.js
@@ -16,11 +16,6 @@ const OPTS = {
const REG = OPTS.registry
-// TODO this ... smells. npm "script-shell" config mentions defaults but those
-// are handled by run-script, not npm. So for now we have to tie tests to some
-// pretty specific internals of runScript
-const makeSpawnArgs = require('@npmcli/run-script/lib/make-spawn-args.js')
-
t.test('packs from local directory', async t => {
const testDir = t.testdir({
'package.json': JSON.stringify({
@@ -152,13 +147,15 @@ t.test('runs scripts in foreground when foregroundScripts === true', async t =>
const cwd = process.cwd()
process.chdir(testDir)
- const [scriptShell, scriptArgs] = makeSpawnArgs({
- event: 'prepack',
- path: testDir,
- cmd: 'touch prepack',
- })
+ const shell = process.platform === 'win32'
+ ? process.env.COMSPEC
+ : 'sh'
+
+ const args = process.platform === 'win32'
+ ? ['/d', '/s', '/c', 'touch prepack']
+ : ['-c', 'touch prepack']
- const prepack = spawk.spawn(scriptShell, scriptArgs)
+ const prepack = spawk.spawn(shell, args)
await pack('file:.', {
packDestination: testDir,
@@ -186,13 +183,7 @@ t.test('doesn\'t run scripts when ignoreScripts === true', async t => {
const cwd = process.cwd()
process.chdir(testDir)
- const [scriptShell, scriptArgs] = makeSpawnArgs({
- event: 'prepack',
- path: testDir,
- cmd: 'touch prepack',
- })
-
- const prepack = spawk.spawn(scriptShell, scriptArgs)
+ const prepack = spawk.spawn('sh', ['-c', 'touch prepack'])
await pack('file:.', {
packDestination: testDir,