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:
authorRuy Adorno <ruyadorno@hotmail.com>2020-10-29 19:30:50 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-10-30 20:31:52 +0300
commit81d6ceef6947e46355eb3ddb05a73da50870dfc1 (patch)
tree0b4f0d542cdf8e873b006eb736c99ef158281aa6 /test/lib/exec.js
parent3990b422d3ff63c54d96b61596bdb8f26a45ca7b (diff)
fix: npm exec on folders missing package.json
This fixes running `npm exec` in folders that does not have a `package.json` file. Fixes: #1975 PR-URL: https://github.com/npm/cli/pull/2081 Credit: @ruyadorno Close: #2081 Reviewed-by: @nlf
Diffstat (limited to 'test/lib/exec.js')
-rw-r--r--test/lib/exec.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/lib/exec.js b/test/lib/exec.js
index 97da01140..fb89776b5 100644
--- a/test/lib/exec.js
+++ b/test/lib/exec.js
@@ -82,7 +82,7 @@ const PATH = require('../../lib/utils/path.js')
let CI_NAME = 'travis-ci'
-const exec = requireInject('../../lib/exec.js', {
+const mocks = {
'@npmcli/arborist': Arborist,
'@npmcli/run-script': runScript,
'@npmcli/ci-detect': () => CI_NAME,
@@ -90,7 +90,8 @@ const exec = requireInject('../../lib/exec.js', {
pacote,
read,
'mkdirp-infer-owner': mkdirp
-})
+}
+const exec = requireInject('../../lib/exec.js', mocks)
t.afterEach(cb => {
MKDIRPS.length = 0
@@ -122,7 +123,7 @@ t.test('npx foo, bin already exists locally', async t => {
t.ifError(er, 'npm exec')
})
t.strictSame(RUN_SCRIPTS, [{
- cmd: 'foo',
+ pkg: { scripts: { npx: 'foo' }},
banner: false,
path: process.cwd(),
stdioString: true,
@@ -146,7 +147,7 @@ t.test('npx foo, bin already exists globally', async t => {
t.ifError(er, 'npm exec')
})
t.strictSame(RUN_SCRIPTS, [{
- cmd: 'foo',
+ pkg: { scripts: { npx: 'foo' }},
banner: false,
path: process.cwd(),
stdioString: true,