@lerna/child-process
Advanced tools
Comparing version 3.16.5 to 4.0.0
@@ -6,2 +6,29 @@ # Change Log | ||
# [4.0.0](https://github.com/lerna/lerna/compare/v3.22.1...v4.0.0) (2021-02-10) | ||
### Features | ||
* **child-process:** Add JSDoc types ([1840492](https://github.com/lerna/lerna/commit/1840492a6b9e832dafe7046157798e3157c2a13b)) | ||
* **deps:** Bump dependencies ([affed1c](https://github.com/lerna/lerna/commit/affed1ce0fce91f01b0a9eafe357db2d985b974f)) | ||
* **deps:** chalk@^4.1.0 ([d2a9ed5](https://github.com/lerna/lerna/commit/d2a9ed537139f49561a7e29b3ebf624c97f48c77)) | ||
* **deps:** execa@^4.1.0 ([9051dca](https://github.com/lerna/lerna/commit/9051dcab1a68b56db09b82ab0345c5f36bcfee2d)) | ||
* **deps:** execa@^5.0.0 ([d8100fd](https://github.com/lerna/lerna/commit/d8100fd9e0742b049ed16ac77e976ce34234ebfc)) | ||
* Drop support for Node v6.x & v8.x ([ff4bb4d](https://github.com/lerna/lerna/commit/ff4bb4da215555e3bb136f5af09b5cbc631e57bb)) | ||
### BREAKING CHANGES | ||
* Node v6.x & v8.x are no longer supported. Please upgrade to the latest LTS release. | ||
Here's the gnarly one-liner I used to make these changes: | ||
``` | ||
npx lerna exec --concurrency 1 --stream -- 'json -I -f package.json -e '"'"'this.engines=this.engines||{};this.engines.node=">= 10.18.0"'"'" | ||
``` | ||
(requires `npm i -g json` beforehand) | ||
## [3.16.5](https://github.com/lerna/lerna/compare/v3.16.4...v3.16.5) (2019-10-07) | ||
@@ -8,0 +35,0 @@ |
73
index.js
@@ -9,2 +9,3 @@ "use strict"; | ||
// bookkeeping for spawned processes | ||
/** @type {Set<import("execa").ExecaChildProcess<string>>} */ | ||
const children = new Set(); | ||
@@ -19,2 +20,8 @@ | ||
/** | ||
* Execute a command asynchronously, piping stdio by default. | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {import("execa").Options} [opts] | ||
*/ | ||
function exec(command, args, opts) { | ||
@@ -27,2 +34,8 @@ const options = Object.assign({ stdio: "pipe" }, opts); | ||
/** | ||
* Execute a command synchronously. | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {import("execa").SyncOptions} [opts] | ||
*/ | ||
function execSync(command, args, opts) { | ||
@@ -32,2 +45,8 @@ return execa.sync(command, args, opts).stdout; | ||
/** | ||
* Spawn a command asynchronously, _always_ inheriting stdio. | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {import("execa").Options} [opts] | ||
*/ | ||
function spawn(command, args, opts) { | ||
@@ -40,2 +59,9 @@ const options = Object.assign({}, opts, { stdio: "inherit" }); | ||
/** | ||
* Spawn a command asynchronously, streaming stdio with optional prefix. | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {import("execa").Options} [opts] | ||
* @param {string} [prefix] | ||
*/ | ||
// istanbul ignore next | ||
@@ -77,3 +103,11 @@ function spawnStreaming(command, args, opts, prefix) { | ||
/** | ||
* @param {import("execa").ExecaError<string>} result | ||
* @returns {number} | ||
*/ | ||
function getExitCode(result) { | ||
if (result.exitCode) { | ||
return result.exitCode; | ||
} | ||
// https://nodejs.org/docs/latest-v6.x/api/child_process.html#child_process_event_close | ||
@@ -85,3 +119,2 @@ if (typeof result.code === "number") { | ||
// https://nodejs.org/docs/latest-v6.x/api/errors.html#errors_error_code | ||
// istanbul ignore else | ||
if (typeof result.code === "string") { | ||
@@ -91,9 +124,14 @@ return os.constants.errno[result.code]; | ||
// istanbul ignore next: extremely weird | ||
throw new TypeError(`Received unexpected exit code value ${JSON.stringify(result.code)}`); | ||
// we tried | ||
return process.exitCode; | ||
} | ||
/** | ||
* @param {string} command | ||
* @param {string[]} args | ||
* @param {import("execa").Options} opts | ||
*/ | ||
function spawnProcess(command, args, opts) { | ||
const child = execa(command, args, opts); | ||
const drain = (code, signal) => { | ||
const drain = (exitCode, signal) => { | ||
children.delete(child); | ||
@@ -105,2 +143,7 @@ | ||
} | ||
// propagate exit code, if any | ||
if (exitCode) { | ||
process.exitCode = exitCode; | ||
} | ||
}; | ||
@@ -120,13 +163,13 @@ | ||
/** | ||
* @param {import("execa").ExecaChildProcess<string> & { pkg?: import("@lerna/package").Package }} spawned | ||
*/ | ||
function wrapError(spawned) { | ||
if (spawned.pkg) { | ||
return spawned.catch(err => { | ||
// istanbul ignore else | ||
if (err.code) { | ||
// ensure code is always a number | ||
err.code = getExitCode(err); | ||
return spawned.catch((err) => { | ||
// ensure exit code is always a number | ||
err.exitCode = getExitCode(err); | ||
// log non-lerna error cleanly | ||
err.pkg = spawned.pkg; | ||
} | ||
// log non-lerna error cleanly | ||
err.pkg = spawned.pkg; | ||
@@ -146,1 +189,7 @@ throw err; | ||
exports.getExitCode = getExitCode; | ||
/** | ||
* @typedef {object} ExecOpts Provided to any execa-based call | ||
* @property {string} cwd | ||
* @property {number} [maxBuffer] | ||
*/ |
{ | ||
"name": "@lerna/child-process", | ||
"version": "3.16.5", | ||
"version": "4.0.0", | ||
"description": "Lerna's internal child_process wrapper", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
"engines": { | ||
"node": ">= 6.9.0" | ||
"node": ">= 10.18.0" | ||
}, | ||
@@ -35,7 +35,7 @@ "publishConfig": { | ||
"dependencies": { | ||
"chalk": "^2.3.1", | ||
"execa": "^1.0.0", | ||
"strong-log-transformer": "^2.0.0" | ||
"chalk": "^4.1.0", | ||
"execa": "^5.0.0", | ||
"strong-log-transformer": "^2.1.0" | ||
}, | ||
"gitHead": "f0574092a2db90142b3a27ec1a4941cddbdcdf62" | ||
"gitHead": "4582c476e07dddddd6b2e3ab6e7f52c1f9eed59a" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11431
148
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcross-spawn@6.0.5(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexeca@1.0.0(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedchalk@^4.1.0
Updatedexeca@^5.0.0