How to use the @lerna/child-process.execSync 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 / utils / describe-ref / lib / describe-ref.js View on Github external
function parse(stdout, options = {}) {
  const minimalShaRegex = /^([0-9a-f]{7,40})(-dirty)?$/;
  // when git describe fails to locate tags, it returns only the minimal sha
  if (minimalShaRegex.test(stdout)) {
    // repo might still be dirty
    const [, sha, isDirty] = minimalShaRegex.exec(stdout);

    // count number of commits since beginning of time
    const refCount = childProcess.execSync("git", ["rev-list", "--count", sha], options);

    return { refCount, sha, isDirty: Boolean(isDirty) };
  }

  const [, lastTagName, lastVersion, refCount, sha, isDirty] =
    /^((?:.*@)?(.*))-(\d+)-g([0-9a-f]+)(-dirty)?$/.exec(stdout) || [];

  return { lastTagName, lastVersion, refCount, sha, isDirty: Boolean(isDirty) };
}
github lerna / lerna / utils / describe-ref / lib / describe-ref.js View on Github external
function sync(options = {}, includeMergedTags) {
  const stdout = childProcess.execSync("git", getArgs(options, includeMergedTags), options);
  const result = parse(stdout, options);

  // only called by collect-updates with no matcher
  log.silly("git-describe.sync", "%j => %j", stdout, result);

  return result;
}
github lerna / lerna / commands / version / lib / is-behind-upstream.js View on Github external
function updateRemote(opts) {
  // git fetch, but for everything
  childProcess.execSync("git", ["remote", "update"], opts);
}
github lerna / lerna / commands / diff / lib / get-last-commit.js View on Github external
function getLastCommit(execOpts) {
  if (hasTags(execOpts)) {
    log.silly("getLastTagInBranch");

    return childProcess.execSync("git", ["describe", "--tags", "--abbrev=0"], execOpts);
  }

  log.silly("getFirstCommit");
  return childProcess.execSync("git", ["rev-list", "--max-parents=0", "HEAD"], execOpts);
}
github lerna / lerna / commands / version / lib / get-current-branch.js View on Github external
function currentBranch(opts) {
  log.silly("currentBranch");

  const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], opts);
  log.verbose("currentBranch", branch);

  return branch;
}
github lerna / lerna / core / git-utils / index.js View on Github external
function hasTags(opts) {
  log.silly("hasTags");
  let result = false;

  try {
    result = !!ChildProcessUtilities.execSync("git", ["tag"], opts);
  } catch (err) {
    log.warn("ENOTAGS", "No git tags were reachable from this branch!");
    log.verbose("hasTags error", err);
  }

  log.verbose("hasTags", result);

  return result;
}
github lerna / lerna / commands / import / index.js View on Github external
execSync(cmd, args) {
    return ChildProcessUtilities.execSync(cmd, args, this.execOpts);
  }
github lerna / lerna / commands / version / lib / get-current-branch.js View on Github external
function currentBranch(opts) {
  log.silly("currentBranch");

  const branch = childProcess.execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], opts);
  log.verbose("currentBranch", branch);

  return branch;
}
github lerna / lerna / core / git-utils / index.js View on Github external
function getLastTag(opts) {
  log.silly("getLastTag");

  const lastTag = ChildProcessUtilities.execSync("git", ["describe", "--tags", "--abbrev=0"], opts);
  log.verbose("getLastTag", lastTag);

  return lastTag;
}

@lerna/child-process

Lerna's internal child_process wrapper

MIT
Latest version published 1 year ago

Package Health Score

84 / 100
Full package analysis