How to use the node-environment-flags.has function in node-environment-flags

To help you get started, we’ve selected a few node-environment-flags examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-node / src / babel-node.js View on Github external
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) {
github mochajs / mocha / lib / cli / node-flags.js View on Github external
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
      ))
  );
};
github mochajs / mocha / lib / cli / unparser.js View on Github external
    .filter(opt => opt in nodeArgs && !nodeEnv.has(opt))
    .forEach(opt => {

node-environment-flags

> Polyfill/shim for `process.allowedNodeEnvironmentFlags`

Apache-2.0
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis

Popular node-environment-flags functions

Similar packages