diff options
author | Ivan <ivanaguilar01@live.com.mx> | 2021-06-22 21:55:18 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-06-23 18:16:18 +0300 |
commit | 78da60ffefcfd457a4432ce1492ee7b53d854450 (patch) | |
tree | 1cf5db290353e7b40fc3ebd22139c7a9b713b1c7 /bin/npx-cli.js | |
parent | 53f81af319f298a0fdd8f143184c3e89770f24ea (diff) |
chore(linting): add bin and clean up lib/ls.js
This adds linting checking to our bin directory, fixes the linting
errors that generated, and cleans up lib/ls.js
to remove unused variables.
PR-URL: https://github.com/npm/cli/pull/3454
Credit: @Ivan12273
Close: #3454
Reviewed-by: @darcyclarke
Diffstat (limited to 'bin/npx-cli.js')
-rwxr-xr-x | bin/npx-cli.js | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/bin/npx-cli.js b/bin/npx-cli.js index a495090c6..7a3fb3983 100755 --- a/bin/npx-cli.js +++ b/bin/npx-cli.js @@ -10,18 +10,18 @@ process.argv.splice(2, 0, 'exec') const removedSwitches = new Set([ 'always-spawn', 'ignore-existing', - 'shell-auto-fallback' + 'shell-auto-fallback', ]) const removedOpts = new Set([ 'npm', 'node-arg', - 'n' + 'n', ]) const removed = new Set([ ...removedSwitches, - ...removedOpts + ...removedOpts, ]) const { definitions, shorthands } = require('../lib/utils/config/index.js') @@ -40,7 +40,7 @@ const switches = new Set([ 'version', 'v', 'help', - 'h' + 'h', ]) // things that do take a value @@ -55,7 +55,7 @@ const opts = new Set([ 'shell', 'npm', 'node-arg', - 'n' + 'n', ]) // break out of loop when we find a positional argument or -- @@ -65,9 +65,9 @@ let i let sawRemovedFlags = false for (i = 3; i < process.argv.length; i++) { const arg = process.argv[i] - if (arg === '--') { + if (arg === '--') break - } else if (/^-/.test(arg)) { + else if (/^-/.test(arg)) { const [key, ...v] = arg.replace(/^-+/, '').split('=') switch (key) { @@ -87,9 +87,8 @@ for (i = 3; i < process.argv.length; i++) { // resolve shorthands and run again if (shorthands[key] && !removed.has(key)) { const a = [...shorthands[key]] - if (v.length) { + if (v.length) a.push(v.join('=')) - } process.argv.splice(i, 1, ...a) i-- continue @@ -110,9 +109,8 @@ for (i = 3; i < process.argv.length; i++) { if (removed.has(key)) { // also remove the value for the cut key. process.argv.splice(i + 1, 1) - } else { + } else i++ - } } } else { // found a positional arg, put -- in front of it, and we're done @@ -121,8 +119,7 @@ for (i = 3; i < process.argv.length; i++) { } } -if (sawRemovedFlags) { +if (sawRemovedFlags) console.error('See `npm help exec` for more information') -} cli(process) |