From db7a0e43983ca19bf004c4292b4ea56890a9daf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= Date: Mon, 29 May 2017 23:57:13 -0700 Subject: [PATCH] fix(opts): allow -- to prevent further parsing --- parse-args.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/parse-args.js b/parse-args.js index 034005b..b7308c8 100644 --- a/parse-args.js +++ b/parse-args.js @@ -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++ } @@ -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 }