Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('for all allowed node environment flags', function() {
// NOTE: this is not stubbing nodeEnvFlags in any way, so relies on
// the userland polyfill to be correct.
nodeEnvFlags.forEach(envFlag => {
it(`${envFlag} should return true`, function() {
expect(isNodeFlag(envFlag), 'to be true');
});
});
});
getV8Flags(function(err, v8Flags) {
for (let i = 0; i < babelArgs.length; i++) {
const arg = babelArgs[i];
const flag = arg.split("=")[0];
if (flag === "-r" || flag === "--require") {
args.push(flag);
args.push(babelArgs[++i]);
} else if (aliases.has(flag)) {
args.unshift(aliases.get(flag));
} else if (
flag === "debug" || // node debug foo.js
flag === "inspect" ||
v8Flags.indexOf(getNormalizedV8Flag(flag)) >= 0 ||
allowedNodeEnvironmentFlags.has(flag)
) {
args.unshift(arg);
} else {
args.push(arg);
}
}
// append arguments passed after --
if (argSeparator > -1) {
args = args.concat(userArgs);
}
try {
const kexec = require("kexec");
kexec(process.argv[0], args);
} catch (err) {
exports.isNodeFlag = (flag, bareword = true) => {
if (!bareword) {
// check if the flag begins with dashes; if not, not a node flag.
if (!/^--?/.test(flag)) {
return false;
}
// strip the leading dashes to match against subsequent checks
flag = flag.replace(/^--?/, '');
}
return (
// treat --require/-r as Mocha flag even though it's also a node flag
!(flag === 'require' || flag === 'r') &&
// check actual node flags from `process.allowedNodeEnvironmentFlags`,
// then historical support for various V8 and non-`NODE_OPTIONS` flags
// and also any V8 flags with `--v8-` prefix
(nodeFlags.has(flag) ||
debugFlags.has(flag) ||
/(?:preserve-symlinks(?:-main)?|harmony(?:[_-]|$)|(?:trace[_-].+$)|gc(?:[_-]global)?$|es[_-]staging$|use[_-]strict$|v8[_-](?!options).+?$)/.test(
flag
))
);
};
.filter(opt => opt in nodeArgs && !nodeEnv.has(opt))
.forEach(opt => {