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
path: root/test
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2021-01-06 22:45:41 +0300
committerisaacs <i@izs.me>2021-01-07 23:43:37 +0300
commit99156df8099f55bc69dfa99d7ddcf8d1d569016e (patch)
tree0cfeac28d87aede855ba4c7d9d0077dd3a1ec421 /test
parenta390d74561b72f0b13cba65844ce60c379198087 (diff)
pass extra arguments directly to run-script as an arraynlf/fix-script-args
fixes #2425 PR-URL: https://github.com/npm/cli/pull/2448 Credit: @nlf Close: #2448 Reviewed-by: @isaacs, @wraithgar, @darcyclarke
Diffstat (limited to 'test')
-rw-r--r--test/lib/exec.js29
1 files changed, 20 insertions, 9 deletions
diff --git a/test/lib/exec.js b/test/lib/exec.js
index 25c3fe463..ac813ade7 100644
--- a/test/lib/exec.js
+++ b/test/lib/exec.js
@@ -124,11 +124,12 @@ t.test('npx foo, bin already exists locally', async t => {
PROGRESS_IGNORED = true
npm.localBin = path
- await exec(['foo'], er => {
+ await exec(['foo', 'one arg', 'two arg'], er => {
t.ifError(er, 'npm exec')
})
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' }},
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -148,11 +149,12 @@ t.test('npx foo, bin already exists globally', async t => {
PROGRESS_IGNORED = true
npm.globalBin = path
- await exec(['foo'], er => {
+ await exec(['foo', 'one arg', 'two arg'], er => {
t.ifError(er, 'npm exec')
})
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' }},
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -178,7 +180,7 @@ t.test('npm exec foo, already present locally', async t => {
},
_from: 'foo@',
}
- await exec(['foo'], er => {
+ await exec(['foo', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -188,6 +190,7 @@ t.test('npm exec foo, already present locally', async t => {
t.equal(PROGRESS_ENABLED, true, 'progress re-enabled')
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -220,6 +223,7 @@ t.test('npm exec <noargs>, run interactive shell', async t => {
if (doRun) {
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'shell-cmd' } },
+ args: [],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -281,7 +285,7 @@ t.test('npm exec foo, not present locally or in central loc', async t => {
},
_from: 'foo@',
}
- await exec(['foo'], er => {
+ await exec(['foo', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -292,6 +296,7 @@ t.test('npm exec foo, not present locally or in central loc', async t => {
const PATH = `${resolve(installDir, 'node_modules', '.bin')}${delimiter}${process.env.PATH}`
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -319,7 +324,7 @@ t.test('npm exec foo, not present locally but in central loc', async t => {
},
_from: 'foo@',
}
- await exec(['foo'], er => {
+ await exec(['foo', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -330,6 +335,7 @@ t.test('npm exec foo, not present locally but in central loc', async t => {
const PATH = `${resolve(installDir, 'node_modules', '.bin')}${delimiter}${process.env.PATH}`
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -357,7 +363,7 @@ t.test('npm exec foo, present locally but wrong version', async t => {
},
_from: 'foo@2.x',
}
- await exec(['foo@2.x'], er => {
+ await exec(['foo@2.x', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -368,6 +374,7 @@ t.test('npm exec foo, present locally but wrong version', async t => {
const PATH = `${resolve(installDir, 'node_modules', '.bin')}${delimiter}${process.env.PATH}`
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foo' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -392,7 +399,7 @@ t.test('npm exec --package=foo bar', async t => {
_from: 'foo@',
}
npm.flatOptions.package = ['foo']
- await exec(['bar'], er => {
+ await exec(['bar', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -402,6 +409,7 @@ t.test('npm exec --package=foo bar', async t => {
t.equal(PROGRESS_ENABLED, true, 'progress re-enabled')
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'bar' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -442,6 +450,7 @@ t.test('npm exec @foo/bar -- --some=arg, locally installed', async t => {
t.equal(PROGRESS_ENABLED, true, 'progress re-enabled')
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'bar' } },
+ args: ['--some=arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -473,7 +482,7 @@ t.test('npm exec @foo/bar, with same bin alias and no unscoped named bin, locall
children: new Map([['@foo/bar', { name: '@foo/bar', version: '1.2.3' }]]),
}
MANIFESTS['@foo/bar'] = foobarManifest
- await exec(['@foo/bar'], er => {
+ await exec(['@foo/bar', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -483,6 +492,7 @@ t.test('npm exec @foo/bar, with same bin alias and no unscoped named bin, locall
t.equal(PROGRESS_ENABLED, true, 'progress re-enabled')
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'baz' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,
@@ -552,7 +562,7 @@ t.test('run command with 2 packages, need install, verify sort', t => {
},
_from: 'bar@',
}
- await exec(['foobar'], er => {
+ await exec(['foobar', 'one arg', 'two arg'], er => {
if (er)
throw er
})
@@ -563,6 +573,7 @@ t.test('run command with 2 packages, need install, verify sort', t => {
const PATH = `${resolve(installDir, 'node_modules', '.bin')}${delimiter}${process.env.PATH}`
t.match(RUN_SCRIPTS, [{
pkg: { scripts: { npx: 'foobar' } },
+ args: ['one arg', 'two arg'],
banner: false,
path: process.cwd(),
stdioString: true,