Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
fix(opts): allow -- to prevent further parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed May 30, 2017
1 parent 460ee11 commit db7a0e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion parse-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ function parseArgs () {
const raw = process.argv

let cmdIndex
let hasDashDash
for (let i = 2; i < raw.length; i++) {
const opt = raw[i]
if (opt[0] === '-') {
if (opt === '--') {
hasDashDash = true
break
} else if (opt[0] === '-') {
if (!bools.has(opt.replace(/^--?/, ''))) {
i++
}
Expand Down Expand Up @@ -100,6 +104,12 @@ function parseArgs () {
parsed.cmdOpts = splitCmd.slice(1)
const pkg = parsed.package || splitCmd[0]
parsed.p = parsed.package = npa(pkg).toString()
} else if (hasDashDash) {
const splitCmd = parsed._
parsed.command = parsed.package
? splitCmd[0]
: npa(splitCmd[0]).name
parsed.cmdOpts = splitCmd.slice(1)
}
return parsed
}
Expand Down

0 comments on commit db7a0e4

Please sign in to comment.