Skip to content

Commit

Permalink
feat: add support for --no-check and --no-quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondill committed Feb 2, 2023
1 parent aaa38d1 commit 10a6067
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ If file/glob is omitted, './package.json' file will be processed.
}

function parseCliArguments() {
const { values: options, positionals: patterns } = parseArgs({
const { values: originalOptions, positionals: patterns } = parseArgs({
options: {
check: { type: 'boolean', short: 'c', default: false },
quiet: { type: 'boolean', short: 'q', default: false },
'no-check': { type: 'boolean', default: false },
'no-quiet': { type: 'boolean', default: false },
version: { type: 'boolean', short: 'v', default: false },
help: { type: 'boolean', short: 'h', default: false },
},
Expand All @@ -44,6 +46,16 @@ function parseCliArguments() {
patterns[0] = 'package.json'
}

// support for negated options
const options = originalOptions
for (const key of Object.keys(originalOptions)) {
// no-check: true --> check: false
if (key.startsWith('no-') && originalOptions[key] === true) {
options[key.slice(3)] = false
delete options[key]
}
}

return { options, patterns }
}

Expand Down

0 comments on commit 10a6067

Please sign in to comment.