execa
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -36,5 +36,7 @@ import {Buffer} from 'node:buffer'; | ||
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above. | ||
@default process.cwd() | ||
*/ | ||
readonly localDir?: string; | ||
readonly localDir?: string | URL; | ||
@@ -115,5 +117,7 @@ /** | ||
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above. | ||
@default process.cwd() | ||
*/ | ||
readonly cwd?: string; | ||
readonly cwd?: string | URL; | ||
@@ -210,2 +214,30 @@ /** | ||
/** | ||
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). | ||
When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `false`. | ||
*Requires Node.js 16 or later.* | ||
@example | ||
```js | ||
import {execa} from 'execa'; | ||
const abortController = new AbortController(); | ||
const subprocess = execa('node', [], {signal: abortController.signal}); | ||
setTimeout(() => { | ||
abortController.abort(); | ||
}, 1000); | ||
try { | ||
await subprocess; | ||
} catch (error) { | ||
console.log(subprocess.killed); // true | ||
console.log(error.isCanceled); // true | ||
} | ||
``` | ||
*/ | ||
readonly signal?: AbortSignal; | ||
/** | ||
If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`. | ||
@@ -343,2 +375,4 @@ | ||
Whether the process was canceled. | ||
You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option. | ||
*/ | ||
@@ -345,0 +379,0 @@ isCanceled: boolean; |
@@ -130,3 +130,3 @@ import {Buffer} from 'node:buffer'; | ||
timedOut, | ||
isCanceled: context.isCanceled, | ||
isCanceled: context.isCanceled || (parsed.options.signal ? parsed.options.signal.aborted : false), | ||
killed: spawned.killed, | ||
@@ -133,0 +133,0 @@ }); |
{ | ||
"name": "execa", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Process execution for humans", | ||
@@ -49,17 +49,18 @@ "license": "MIT", | ||
"merge-stream": "^2.0.0", | ||
"npm-run-path": "^5.0.1", | ||
"npm-run-path": "^5.1.0", | ||
"onetime": "^6.0.0", | ||
"signal-exit": "^3.0.5", | ||
"signal-exit": "^3.0.7", | ||
"strip-final-newline": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.11.7", | ||
"ava": "^3.15.0", | ||
"c8": "^7.10.0", | ||
"@types/node": "^17.0.17", | ||
"ava": "^4.0.1", | ||
"c8": "^7.11.0", | ||
"get-node": "^12.0.0", | ||
"is-running": "^2.1.0", | ||
"p-event": "^5.0.1", | ||
"semver": "^7.3.5", | ||
"tempfile": "^4.0.0", | ||
"tsd": "^0.18.0", | ||
"xo": "^0.46.4" | ||
"tsd": "^0.19.1", | ||
"xo": "^0.48.0" | ||
}, | ||
@@ -76,3 +77,9 @@ "c8": { | ||
] | ||
}, | ||
"xo": { | ||
"rules": { | ||
"unicorn/no-empty-file": "off", | ||
"@typescript-eslint/ban-types": "off" | ||
} | ||
} | ||
} |
@@ -86,6 +86,7 @@ <img src="media/logo.svg" width="400"> | ||
const subprocess = execa('node'); | ||
const abortController = new AbortController(); | ||
const subprocess = execa('node', [], {signal: abortController.signal}); | ||
setTimeout(() => { | ||
subprocess.cancel(); | ||
abortController.abort(); | ||
}, 1000); | ||
@@ -175,6 +176,2 @@ | ||
#### cancel() | ||
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. | ||
#### all | ||
@@ -295,2 +292,4 @@ | ||
You can cancel the spawned process using the [`signal`](#signal-1) option. | ||
#### killed | ||
@@ -363,3 +362,3 @@ | ||
Type: `string`\ | ||
Type: `string | URL`\ | ||
Default: `process.cwd()` | ||
@@ -369,2 +368,4 @@ | ||
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above. | ||
#### execPath | ||
@@ -454,3 +455,3 @@ | ||
Type: `string`\ | ||
Type: `string | URL`\ | ||
Default: `process.cwd()` | ||
@@ -460,2 +461,4 @@ | ||
Using a `URL` is only supported in Node.js `14.18.0`, `16.14.0` or above. | ||
#### env | ||
@@ -552,2 +555,12 @@ | ||
#### signal | ||
Type: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) | ||
You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). | ||
When `AbortController.abort()` is called, [`.isCanceled`](#iscanceled) becomes `false`. | ||
*Requires Node.js 16 or later.* | ||
#### windowsVerbatimArguments | ||
@@ -554,0 +567,0 @@ |
58260
996
668
10
Updatednpm-run-path@^5.1.0
Updatedsignal-exit@^3.0.7