Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v7.19.0 #3465

Merged
merged 15 commits into from
Jun 24, 2021
Merged
Prev Previous commit
Next Next commit
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: #3454
Credit: @Ivan12273
Close: #3454
Reviewed-by: @darcyclarke
  • Loading branch information
Ivan12273 authored and wraithgar committed Jun 23, 2021
commit 78da60ffefcfd457a4432ce1492ee7b53d854450
23 changes: 10 additions & 13 deletions bin/npx-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -40,7 +40,7 @@ const switches = new Set([
'version',
'v',
'help',
'h'
'h',
])

// things that do take a value
Expand All @@ -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 --
Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
4 changes: 0 additions & 4 deletions lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ class LS extends ArboristWorkspaceCmd {
dev,
development,
link,
node,
prod,
production,
only,
tree,
}))
.map(mapEdgesToNodes({ seenPaths }))
.concat(appendExtraneousChildren({ node, seenPaths }))
Expand Down Expand Up @@ -392,11 +390,9 @@ const filterByEdgesTypes = ({
dev,
development,
link,
node,
prod,
production,
only,
tree,
}) => {
// filter deps by type, allows for: `npm ls --dev`, `npm ls --prod`,
// `npm ls --link`, `npm ls --only=dev`, etc
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"sudotest:nocleanup": "sudo NO_TEST_CLEANUP=1 npm run test --",
"posttest": "npm run lint",
"eslint": "eslint",
"lint": "npm run eslint -- test/lib test/bin lib scripts docs smoke-tests",
"lint": "npm run eslint -- test/lib test/bin bin lib scripts docs smoke-tests",
"lintfix": "npm run lint -- --fix",
"prelint": "rimraf test/npm_cache*",
"resetdeps": "bash scripts/resetdeps.sh",
Expand Down