diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2022-04-05 01:39:30 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-04-20 02:28:18 +0300 |
commit | b06e89f434fe8f104e71d4d8b5c98f1e866efdfa (patch) | |
tree | 0c20cea0ba78c4b9885bee150c22bc6d5f302a9a /test | |
parent | f3d7fff82dfb742704abfeb58b178a35702c0a8f (diff) |
fix(install): do not install invalid package name
Throws an usage error if finding an invalid argument in global install.
Fixes: https://github.com/npm/cli/issues/3029
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/commands/install.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/lib/commands/install.js b/test/lib/commands/install.js index afb6adb4f..9b2d52f6e 100644 --- a/test/lib/commands/install.js +++ b/test/lib/commands/install.js @@ -139,6 +139,23 @@ t.test('should install globally using Arborist', async t => { t.strictSame(SCRIPTS, [], 'no scripts when installing globally') }) +t.test('should not install invalid global package name', async t => { + const { npm } = await loadMockNpm(t, { + '@npmcli/run-script': () => {}, + '../../lib/utils/reify-finish.js': async () => {}, + '@npmcli/arborist': function (args) { + throw new Error('should not reify') + }, + }) + npm.config.set('global', true) + npm.globalPrefix = path.resolve(t.testdir({})) + await t.rejects( + npm.exec('install', ['']), + /Usage:/, + 'should not install invalid package name' + ) +}) + t.test('npm i -g npm engines check success', async t => { const { npm } = await loadMockNpm(t, { '../../lib/utils/reify-finish.js': async () => {}, |