How to use the @lerna/child-process.exec function in @lerna/child-process

To help you get started, we’ve selected a few @lerna/child-process 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 lerna / lerna / commands / publish / lib / verify-npm-registry.js View on Github external
}

  const args = [
    "ping",
    // immediate feedback from request errors, not excruciatingly slow retries
    // @see https://docs.npmjs.com/misc/config#fetch-retries
    "--fetch-retries=0",
    // including http requests makes raw logging easier to debug for end users
    "--loglevel=http",
  ];
  const opts = getExecOpts({ location }, registry);

  // we do not need special log handling
  delete opts.pkg;

  return childProcess.exec("npm", args, opts).catch(({ stderr }) => {
    // Log the error cleanly to stderr, it already has npmlog decorations
    log.pause();
    console.error(stderr); // eslint-disable-line no-console
    log.resume();

    throw new ValidationError("EREGISTRY", "Connection to npm registry failed");
  });
}
github lerna / lerna / commands / publish / lib / get-tagged-packages.js View on Github external
function getTaggedPackages(packageGraph, rootPath, opts) {
  log.silly("getTaggedPackages");

  // @see https://stackoverflow.com/a/424142/5707
  // FIXME: --root is only necessary for tests :P
  return childProcess
    .exec("git", ["diff-tree", "--name-only", "--no-commit-id", "--root", "-r", "-c", "HEAD"], opts)
    .then(({ stdout }) => {
      const manifests = stdout.split("\n").filter(fp => path.basename(fp) === "package.json");
      const locations = new Set(manifests.map(fp => path.join(rootPath, path.dirname(fp))));

      return Array.from(packageGraph.values()).filter(node => locations.has(node.location));
    });
}
github lerna / lerna / commands / import / index.js View on Github external
tracker.info(sha);

      const patch = this.createPatchForCommit(sha);
      const procArgs = ["am", "-3", "--keep-non-patch"];

      if (this.options.preserveCommit) {
        this.configureGitUser(this.getGitUserFromSha(sha));
        procArgs.push("--committer-date-is-author-date");
      }

      // Apply the modified patch to the current lerna repository, preserving
      // original commit date, author and message.
      //
      // Fall back to three-way merge, which can help with duplicate commits
      // due to merge history.
      const proc = ChildProcessUtilities.exec("git", procArgs, this.execOpts);

      proc.stdin.end(patch);

      return pulseTillDone(proc)
        .then(() => {
          tracker.completeWork(1);
        })
        .catch(err => {
          if (err.stdout.indexOf("Patch is empty.") === 0) {
            tracker.completeWork(1);

            // Automatically skip empty commits
            return ChildProcessUtilities.exec("git", ["am", "--skip"], this.execOpts);
          }

          err.sha = sha;
github lerna / lerna / commands / publish / lib / get-current-tags.js View on Github external
function getCurrentTags(execOpts, matchingPattern) {
  log.silly("getCurrentTags", "matching %j", matchingPattern);

  const opts = Object.assign({}, execOpts, {
    // don't reject due to non-zero exit code when there are no results
    reject: false,
  });

  return childProcess
    .exec("git", ["tag", "--sort", "version:refname", "--points-at", "HEAD", "--list", matchingPattern], opts)
    .then(result => {
      const lines = result.stdout.split("\n").filter(Boolean);

      if (matchingPattern === "*@*") {
        // independent mode does not respect tagVersionPrefix,
        // but embeds the package name in the tag "prefix"
        return lines.map(tag => npa(tag).name);
      }

      // "fixed" mode can have a custom tagVersionPrefix,
      // but it doesn't really matter as it is not used to extract package names
      return lines;
    });
}
github lerna / lerna / utils / npm-install / npm-install.js View on Github external
args.push("--non-interactive");
  }

  if (npmClientArgs && npmClientArgs.length) {
    args.push(...npmClientArgs);
  }

  // potential override, e.g. "inherit" in root-only bootstrap
  opts.stdio = stdio;

  // provide env sentinels to avoid recursive execution from scripts
  opts.env.LERNA_EXEC_PATH = pkg.location;
  opts.env.LERNA_ROOT_PATH = pkg.rootPath;

  log.silly("npmInstall", [cmd, args]);
  return ChildProcessUtilities.exec(cmd, args, opts);
}
github lerna / lerna / commands / version / lib / git-add.js View on Github external
function gitAdd(files, opts) {
  log.silly("gitAdd", files);

  const filePaths = files.map(file => slash(path.relative(opts.cwd, path.resolve(opts.cwd, file))));

  return childProcess.exec("git", ["add", "--", ...filePaths], opts);
}
github lerna / lerna / commands / version / lib / git-push.js View on Github external
function gitPush(remote, branch, opts) {
  log.silly("gitPush", remote, branch);

  return childProcess.exec("git", ["push", "--follow-tags", "--no-verify", remote, branch], opts);
}
github lerna / lerna / commands / version / lib / git-push.js View on Github external
function gitPush(remote, branch, opts) {
  log.silly("gitPush", remote, branch);

  return childProcess.exec("git", ["push", "--follow-tags", "--no-verify", remote, branch], opts);
}
github lerna / lerna / commands / publish / lib / git-checkout.js View on Github external
function gitCheckout(files, opts) {
  log.silly("gitCheckout", files);

  return childProcess.exec("git", ["checkout", "--"].concat(files), opts);
}
github lerna / lerna / utils / describe-ref / lib / describe-ref.js View on Github external
function describeRef(options = {}, includeMergedTags) {
  const promise = childProcess.exec("git", getArgs(options, includeMergedTags), options);

  return promise.then(({ stdout }) => {
    const result = parse(stdout, options);

    log.verbose("git-describe", "%j => %j", options && options.match, stdout);
    log.silly("git-describe", "parsed => %j", result);

    return result;
  });
}

@lerna/child-process

Lerna's internal child_process wrapper

MIT
Latest version published 1 year ago

Package Health Score

84 / 100
Full package analysis