Comparing version 6.0.0 to 6.1.0
# node-dev | ||
## v6.1.0 / 2020-10-15 | ||
- Manually wrangle node args so that we can handle `--` args coming before `-` args (Fixes #236) | ||
## v6.0.0 / 2020-10-14 | ||
@@ -4,0 +8,0 @@ |
@@ -12,14 +12,18 @@ const minimist = require('minimist'); | ||
const doubleDash = s => /^--/.test(s); | ||
const dash = s => /^-[^-]*$/.test(s); | ||
function getFirstNonOptionArgIndex(args) { | ||
for (let i = 2; i < args.length; i += 1) { | ||
if (args[i][0] != '-') return i; | ||
if (!doubleDash(args[i]) && !dash(args[i]) && !dash(args[i - 1] || '')) return i; | ||
} | ||
return args.length; | ||
return args.length - 1; | ||
} | ||
module.exports = argv => { | ||
const nodeArgs = []; | ||
const unknownArgs = []; | ||
const scriptIndex = getFirstNonOptionArgIndex(argv); | ||
const script = argv[scriptIndex]; | ||
@@ -33,11 +37,21 @@ const scriptArgs = argv.slice(scriptIndex + 1); | ||
default: getConfig(script), | ||
unknown: function (arg) { | ||
const argKeys = Object.keys(minimist([arg])); | ||
unknown: arg => { | ||
const key = Object.keys(minimist([arg]))[1]; | ||
if (configKeys.some(k => argKeys.includes(k))) { | ||
return true; | ||
if (!configKeys.includes(key)) { | ||
unknownArgs.push({ arg, key }); | ||
} | ||
} | ||
}); | ||
nodeArgs.push(arg); | ||
const nodeArgs = unknownArgs.reduce((out, { arg, key }) => { | ||
out.push(arg); | ||
if (typeof opts[key] !== 'boolean' && !arg.includes('=')) { | ||
out.push(opts[key]); | ||
} | ||
return out; | ||
}, []); | ||
unknownArgs.forEach(({ key }) => { | ||
delete opts[key]; | ||
}); | ||
@@ -44,0 +58,0 @@ |
{ | ||
"name": "node-dev", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Restarts your app when files are modified", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32409
459