Skip to content

Commit

Permalink
refactor(child-process): Centralize ExecOpts type
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Dec 10, 2020
1 parent 496552d commit 556056a
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 12 deletions.
4 changes: 2 additions & 2 deletions commands/diff/lib/get-last-commit.js
Expand Up @@ -6,7 +6,7 @@ const childProcess = require("@lerna/child-process");
module.exports.getLastCommit = getLastCommit;

/**
* @param {{ cwd: string }} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
*/
function getLastCommit(execOpts) {
if (hasTags(execOpts)) {
Expand All @@ -20,7 +20,7 @@ function getLastCommit(execOpts) {
}

/**
* @param {{ cwd: string }} opts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function hasTags(opts) {
let result = false;
Expand Down
2 changes: 1 addition & 1 deletion commands/diff/lib/has-commit.js
Expand Up @@ -6,7 +6,7 @@ const childProcess = require("@lerna/child-process");
module.exports.hasCommit = hasCommit;

/**
* @param {{ cwd: string }} opts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function hasCommit(opts) {
log.silly("hasCommit");
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-current-sha.js
Expand Up @@ -7,7 +7,7 @@ module.exports.getCurrentSHA = getCurrentSHA;

/**
* Retrieve current SHA from git.
* @param {CommandExecOpts} opts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function getCurrentSHA(opts) {
log.silly("getCurrentSHA");
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-current-tags.js
Expand Up @@ -8,7 +8,7 @@ module.exports.getCurrentTags = getCurrentTags;

/**
* Retrieve a list of git tags pointing to the current HEAD that match the provided pattern.
* @param {CommandExecOpts} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
* @param {string} matchingPattern
* @returns {string[]}
*/
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/get-tagged-packages.js
Expand Up @@ -10,7 +10,7 @@ module.exports.getTaggedPackages = getTaggedPackages;
* Retrieve a list of graph nodes for packages that were tagged in a non-independent release.
* @param {import("@lerna/package-graph").PackageGraph} packageGraph
* @param {string} rootPath
* @param {{ cwd: string }} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
* @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
*/
function getTaggedPackages(packageGraph, rootPath, execOpts) {
Expand Down
2 changes: 1 addition & 1 deletion commands/publish/lib/git-checkout.js
Expand Up @@ -9,7 +9,7 @@ module.exports.gitCheckout = gitCheckout;
* Reset files modified by publish steps.
* @param {string[]} stagedFiles
* @param {{ granularPathspec: boolean; }} gitOpts
* @param {CommandExecOpts} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
*/
function gitCheckout(stagedFiles, gitOpts, execOpts) {
const files = gitOpts.granularPathspec ? stagedFiles : ".";
Expand Down
6 changes: 6 additions & 0 deletions core/child-process/index.js
Expand Up @@ -138,3 +138,9 @@ exports.spawn = spawn;
exports.spawnStreaming = spawnStreaming;
exports.getChildProcessCount = getChildProcessCount;
exports.getExitCode = getExitCode;

/**
* @typedef {object} ExecOpts Provided to any execa-based call
* @property {string} cwd
* @property {number} [maxBuffer]
*/
2 changes: 2 additions & 0 deletions core/command/index.js
Expand Up @@ -178,6 +178,8 @@ class Command {

this.concurrency = Math.max(1, +concurrency || DEFAULT_CONCURRENCY);
this.toposort = sort === undefined || sort;

/** @type {import("@lerna/child-process").ExecOpts} */
this.execOpts = {
cwd: this.project.rootPath,
maxBuffer,
Expand Down
2 changes: 1 addition & 1 deletion core/filter-options/lib/get-filtered-packages.js
Expand Up @@ -23,7 +23,7 @@ module.exports.getFilteredPackages = getFilteredPackages;
/**
* Retrieve a list of Package instances filtered by various options.
* @param {import("@lerna/package-graph").PackageGraph} packageGraph
* @param {{ cwd: string }} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
* @param {Partial<FilterOptions>} opts
* @returns {Promise<import("@lerna/package").Package[]>}
*/
Expand Down
2 changes: 1 addition & 1 deletion utils/collect-updates/collect-updates.js
Expand Up @@ -34,7 +34,7 @@ module.exports.getPackagesForOption = getPackagesForOption;
* Create a list of graph nodes representing packages changed since the previous release, tagged or otherwise.
* @param {import("@lerna/package").Package[]} filteredPackages
* @param {import("@lerna/package-graph").PackageGraph} packageGraph
* @param {{ cwd: string }} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
* @param {UpdateCollectorOptions} commandOptions
*/
function collectUpdates(filteredPackages, packageGraph, execOpts, commandOptions) {
Expand Down
2 changes: 1 addition & 1 deletion utils/collect-updates/lib/has-tags.js
Expand Up @@ -7,7 +7,7 @@ module.exports.hasTags = hasTags;

/**
* Determine if any git tags are reachable.
* @param {{ cwd: string }} opts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function hasTags(opts) {
log.silly("hasTags");
Expand Down
4 changes: 2 additions & 2 deletions utils/collect-updates/lib/make-diff-predicate.js
Expand Up @@ -10,7 +10,7 @@ module.exports.makeDiffPredicate = makeDiffPredicate;

/**
* @param {string} committish
* @param {{ cwd: string }} execOpts
* @param {import("@lerna/child-process").ExecOpts} execOpts
* @param {string[]} ignorePatterns
*/
function makeDiffPredicate(committish, execOpts, ignorePatterns = []) {
Expand Down Expand Up @@ -60,7 +60,7 @@ function makeDiffPredicate(committish, execOpts, ignorePatterns = []) {
/**
* @param {string} committish
* @param {string} location
* @param {{ cwd: string }} opts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function diffSinceIn(committish, location, opts) {
const args = ["diff", "--name-only", committish];
Expand Down

0 comments on commit 556056a

Please sign in to comment.