@swiftuijs/twill-shell 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,38 +1,73 @@
1
1
  # <img src="https://twill.evecalm.com/logo.png" alt="Twill hummingbird" align="right" width="40" height="40" /> Twill shell
2
2
 
3
- Swift-inspired subprocess tools for Twill and ordinary Node JS/TS scripts, available in 0.2.0.
3
+ Swift-inspired subprocess tools for Twill and ordinary Node JS/TS scripts, Node-based in 0.3.0.
4
+
5
+ ## Install in your project
6
+
7
+ Use Node 24 LTS for a new setup (supported range: `^20.19.0 || >=22.12.0`). Run from the directory containing your `package.json`; for a new project, run `npm init -y` first. Install the SDK as a production dependency:
4
8
 
5
9
  ```sh
6
- npm install @swiftuijs/twill-shell
7
- # For .twill source scripts:
8
- npm install --save-dev @swiftuijs/twill
10
+ npm install @swiftuijs/twill-shell@0.3.0
9
11
  ```
10
12
 
11
- Commands execute through one Rust process engine with literal argv, without shell interpretation or command compilation (`shell: false`). The prebuilt implementation dependency installs automatically; users need no Rust toolchain and do not choose a backend. Native JS/TS needs no Twill compiler. One async reactor per Node environment coordinates already-started children and pipes independently of libuv's worker pool.
13
+ With pnpm, use `pnpm add @swiftuijs/twill-shell@0.3.0`. This package supplies the process API; `@swiftuijs/twill` supplies the optional Twill source runner. A global compiler does not make this SDK available to project imports. Keep Twill packages on the same version.
14
+
15
+ ## Run ordinary JavaScript
16
+
17
+ The SDK uses Node spawn/streams with literal argv (`shell: false`), bounded capture and owned cancellation/timeout teardown. It has zero production dependencies; native JS/TS needs no Twill compiler or Rust toolchain.
18
+
19
+ Changed in 0.3.0: the SDK no longer depends on `@swiftuijs/twill-shell-native`. Older npm 0.2.0 still requires the retired Rust addon; its versions remain downloadable for compatibility. The public command/policy/error API remains; abrupt worker/process-exit cleanup and unnamed Unix signal reporting change to Node's boundaries. See the [scripting guide](https://twill.evecalm.com/scripting#execution-and-version-boundary).
12
20
 
13
- Supported prebuilds: Linux glibc x64/ARM64 (glibc 2.28+), Linux musl x64/ARM64 (musl 1.2.5+), macOS x64/ARM64 and Windows x64/ARM64. Missing/incompatible binaries and unsupported platforms reject before launch, without fallback, install-time builds or downloads. See [performance](https://twill.evecalm.com/performance#rust-shell-backend) for measured warm gains and cold/polling limits.
21
+ Save this as `command.mjs`:
14
22
 
15
- ```twill
16
- #!/usr/bin/env twill
23
+ ```js
17
24
  import { Command, Output, Subprocess } from '@swiftuijs/twill-shell';
18
25
 
19
- const result = await Subprocess.run(Command.name('git', ['status', '--short']), {
20
- output: Output.text({ limit: 64 * 1024 }),
21
- timeoutMs: 5000,
22
- });
23
- console.log(result.standardOutput);
26
+ const result = await Subprocess.run(
27
+ Command.path(process.execPath, ['-e', 'console.log("Hello from a child process")']),
28
+ { output: Output.text({ limit: 64 * 1024 }), timeoutMs: 5000 },
29
+ );
30
+ console.log(result.standardOutput.trim());
31
+ ```
32
+
33
+ Run `node command.mjs`. Expected output is `Hello from a child process`. This works without Git, a Twill compiler or a global installation. Native TypeScript uses your existing TS runner/build.
34
+
35
+ ## Run Twill source
36
+
37
+ Install the compiler as well:
38
+
39
+ ```sh
40
+ npm install --save-dev @swiftuijs/twill@0.3.0
41
+ # pnpm add -D @swiftuijs/twill@0.3.0
42
+ ```
43
+
44
+ Copy the JavaScript example to `command.twill` and add `#!/usr/bin/env twill` as its first line. Use the local command:
45
+
46
+ ```sh
47
+ npm exec -- twill command.twill
48
+ # pnpm exec twill command.twill
24
49
  ```
25
50
 
26
- The compiler runner supplies the `twill` binary. Save this as `status.twill`, then use `twill status.twill` or `twill run status.twill`. On Linux/macOS, `chmod +x status.twill` enables `./status.twill` when `twill` is on PATH; `pnpm exec ./status.twill` uses a project-local binary. Windows uses the explicit CLI. Arguments after the script path pass through unchanged. Application dependencies resolve from the script's location. Use the compiler and SDK from 0.2.0 or newer.
51
+ On Linux/macOS, `chmod +x command.twill` enables `npm exec --call './command.twill'` or `pnpm exec ./command.twill`. To run `./command.twill` directly, install the compiler globally with `npm install --global @swiftuijs/twill@0.3.0` and keep its executable directory on PATH. Windows uses the explicit CLI. Arguments after the script path pass through unchanged. Application dependencies resolve from the script's location. Use compiler and SDK 0.3.0 or newer.
52
+
53
+ For package scripts, Node type declarations, error handling and troubleshooting, follow the [complete shell scripting guide](https://twill.evecalm.com/scripting). [Getting started](https://twill.evecalm.com/getting-started) covers application modules and build integration.
54
+
55
+ ## Process contracts
27
56
 
28
57
  Use `Command.path(absolutePath, args)` for a trusted executable; `Command.name(name, args)` uses native PATH search. Arguments are immutable snapshots and remain literal strings, including spaces, quotes, newlines and shell metacharacters. Tool-specific options still matter: use `--` before user-supplied filenames when the executable supports it.
29
58
 
30
59
  Stdin defaults to EOF; stdout/stderr inherit without capture. `Input.inherit()` inherits stdin; a string or `Uint8Array` writes input with native backpressure. Byte input is copied at submission; cwd and environment are snapshotted then. `Output.text({limit})` and `Output.bytes({limit})` require positive byte limits; `Output.discard()` retains nothing. Output-limit failure rejects after teardown, never returns silent truncation. Capture limits bound retained stream bytes, not total process memory or the final UTF-8 string/buffer allocation.
31
60
 
32
- Named Unix signals use Node names; unnamed signals retain their numeric OS value. A successful result contains `processIdentifier`, `terminationStatus`, `standardOutput` and `standardError`. Nonzero/signal exits reject with `ProcessExitError`; `check: false` returns that status. Launch/I/O failures, abort, timeout and output overflow always reject. Use ordinary `try/catch` and exported error classes. Errors can carry bounded output and native causes; the SDK never logs them automatically.
61
+ From 0.3.0, statuses follow Node reports, including its unnamed-signal limitations. Released 0.2.0 preserves numeric unnamed Unix signals. A successful result contains `processIdentifier`, `terminationStatus`, `standardOutput` and `standardError`. Nonzero/signal exits reject with `ProcessExitError`; `check: false` returns that status. Launch/I/O failures, abort, timeout and output overflow always reject. Use ordinary `try/catch` and exported error classes. Errors can carry bounded output and native causes; the SDK never logs them automatically.
33
62
 
34
63
  `cwd` and `Environment.inherit(updates)` / `.replace(values)` apply only to the child. Pass an `AbortSignal` or `timeoutMs` for cancellation. The default grace period is 250 ms before forced termination, followed by at most 1000 ms joining time. Settlement normally waits for child close and owned I/O. Failed teardown reports `unresolvedProcessIdentifier` and `cleanupErrors`, preserving the first failure. Ownership covers the direct child; descendants and arbitrary process trees are outside this contract. Windows uses its native process handle for termination, without POSIX graceful-signal guarantees.
35
64
 
36
65
  This first stage does not implement scoped streaming, pipelines, shell templates or shell-text execution. Node ESM is required (`^20.19.0 || >=22.12.0`). Twill source execution uses its existing loader; exported/native JS only needs this SDK. See the [scripting guide](https://twill.evecalm.com/scripting), [RFC 0034](https://github.com/swiftuijs/twill/blob/main/docs/rfcs/0034-shell-scripting-toolkit.md) and [official AI skill](https://twill.evecalm.com/ai). Twill's sibling UI project is [SwiftUI.js](https://swiftuijs.evecalm.com/).
37
66
 
38
- Worker termination cancels that environment's children. Explicit `process.exit()` and environment teardown use a native cleanup barrier bounded to 1.1 seconds; JS callbacks do not run during exit. OS creation/uninterruptible kernel waits are not hard real-time guarantees, and SIGKILL/native faults cannot run cleanup handlers.
67
+ Cancel and await outstanding work before a worker shuts down. Set `process.exitCode` after awaited work; forced `Worker.terminate()` and `process.exit()` cannot perform an asynchronous join. Version 0.3.0 removes the old native cleanup barrier. OS creation and event-loop scheduling are not hard real-time deadlines.
68
+
69
+ Bounded capture and lifecycle checks add overhead. The reviewed Linux/Node 24 report measured about 17% median overhead for native dual 1 MiB capture and 11% for full duplex, accepted for 0.3.0. See the [recorded costs](https://twill.evecalm.com/performance#node-shell-sdk); this is not a universal native-parity guarantee.
70
+
71
+ ## Development
72
+
73
+ This package's implementation uses Twill and emits ordinary JavaScript. Build and check a checkout with the workspace tools; see [developing tooling in Twill](https://github.com/swiftuijs/twill/blob/main/docs/contributing/dogfooding.md) for bootstrap and contribution instructions.
package/dist/cwd.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cwd.d.ts","sourceRoot":"","sources":["../src/cwd.ts"],"names":[],"mappings":"AACA,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,kBAAmB,EAC3B,MAAM,SAAgB,GACrB,MAAM,CAQR"}
1
+ {"version":3,"file":"cwd.d.ts","mappings":"AACA,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,kBAAmB,EAC3B,MAAM,SAAgB,GACrB,MAAM","names":[],"ignoreList":[],"sources":["../src/cwd.twill"]}
package/dist/cwd.js CHANGED
@@ -1,11 +1,9 @@
1
- import { isAbsolute, win32 } from 'node:path';
2
- export function cwdSnapshot(cwd, platform = process.platform, parent = process.cwd()) {
3
- return cwd === undefined
4
- ? parent
5
- : platform === 'win32'
6
- ? win32.resolve(parent, cwd)
7
- : isAbsolute(cwd)
8
- ? cwd
9
- : `${parent}/${cwd}`;
1
+ import { isAbsolute, win32 } from "node:path";
2
+ //#region src/cwd.twill
3
+ function cwdSnapshot(cwd, platform = process.platform, parent = process.cwd()) {
4
+ return cwd === void 0 ? parent : platform === "win32" ? win32.resolve(parent, cwd) : isAbsolute(cwd) ? cwd : `${parent}/${cwd}`;
10
5
  }
6
+ //#endregion
7
+ export { cwdSnapshot };
8
+
11
9
  //# sourceMappingURL=cwd.js.map
package/dist/cwd.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cwd.js","sourceRoot":"","sources":["../src/cwd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC9C,MAAM,UAAU,WAAW,CACzB,GAAuB,EACvB,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAC3B,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;IAEtB,OAAO,GAAG,KAAK,SAAS;QACtB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,QAAQ,KAAK,OAAO;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;YAC5B,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;gBACf,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"cwd.js","names":[],"sources":["../src/cwd.twill"],"mappings":";;AACA,SAAgB,YACd,KACA,WAAW,QAAQ,UACnB,SAAS,QAAQ,IAAG,GAAE;CAEtB,OAAO,QAAQ,KAAA,IACX,SACA,aAAa,UACX,MAAM,QAAQ,QAAQ,GAAG,IACzB,WAAW,GAAG,IACZ,MACA,GAAG,OAAM,GAAI;AACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAiB/C,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,kBAAmB,EAC3B,MAAM,oBAAc;;EAgBrB"}
1
+ {"version":3,"file":"environment.d.ts","mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAgB;AAiBjD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,QAAQ,kBAAmB,EAC3B,MAAM,oBAAc","names":[],"ignoreList":[],"sources":["../src/environment.twill"]}
@@ -1,32 +1,32 @@
1
- import { childEnvironment } from './values.js';
2
- // Match Node/libuv's mandatory Windows spawn environment additions (including
3
- // replacement/removal policies). Explicit empty values still override defaults.
4
- const windowsRequired = [
5
- 'HOMEDRIVE',
6
- 'HOMEPATH',
7
- 'LOGONSERVER',
8
- 'PATH',
9
- 'SYSTEMDRIVE',
10
- 'SYSTEMROOT',
11
- 'TEMP',
12
- 'USERDOMAIN',
13
- 'USERNAME',
14
- 'USERPROFILE',
15
- 'WINDIR',
1
+ import { childEnvironment } from "./values.js";
2
+ //#region src/environment.twill
3
+ var windowsRequired = [
4
+ "HOMEDRIVE",
5
+ "HOMEPATH",
6
+ "LOGONSERVER",
7
+ "PATH",
8
+ "SYSTEMDRIVE",
9
+ "SYSTEMROOT",
10
+ "TEMP",
11
+ "USERDOMAIN",
12
+ "USERNAME",
13
+ "USERPROFILE",
14
+ "WINDIR"
16
15
  ];
17
- export function environmentSnapshot(policy, platform = process.platform, parent = process.env) {
18
- const environment = { ...(childEnvironment(policy, platform) ?? parent) };
19
- if (parent.NODE_V8_COVERAGE && !Object.hasOwn(environment, 'NODE_V8_COVERAGE'))
20
- environment.NODE_V8_COVERAGE = parent.NODE_V8_COVERAGE;
21
- if (platform === 'win32') {
22
- const selected = new Set(Object.keys(environment).map((key) => key.toUpperCase()));
23
- const inherited = new Map(Object.entries(parent).map(([key, value]) => [key.toUpperCase(), value]));
24
- for (const key of windowsRequired) {
25
- const value = inherited.get(key);
26
- if (!selected.has(key) && value !== undefined)
27
- environment[key] = value;
28
- }
29
- }
30
- return environment;
16
+ function environmentSnapshot(policy, platform = process.platform, parent = process.env) {
17
+ const environment = { ...childEnvironment(policy, platform) ?? parent };
18
+ if (parent.NODE_V8_COVERAGE && !Object.hasOwn(environment, "NODE_V8_COVERAGE")) environment.NODE_V8_COVERAGE = parent.NODE_V8_COVERAGE;
19
+ if (platform === "win32") {
20
+ const selected = new Set(Object.keys(environment).map((key) => key.toUpperCase()));
21
+ const inherited = new Map(Object.entries(parent).map(([key, value]) => [key.toUpperCase(), value]));
22
+ for (const key of windowsRequired) {
23
+ const value = inherited.get(key);
24
+ if (!selected.has(key) && value !== void 0) environment[key] = value;
25
+ }
26
+ }
27
+ return environment;
31
28
  }
29
+ //#endregion
30
+ export { environmentSnapshot };
31
+
32
32
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,8EAA8E;AAC9E,gFAAgF;AAChF,MAAM,eAAe,GAAG;IACtB,WAAW;IACX,UAA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1
+ {"version":3,"file":"environment.js","names":[],"sources":["../src/environment.twill"],"mappings":";;AAKA,IAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AACD,SAAgB,oBACd,QACA,WAAW,QAAQ,UACnB,SAAS,QAAQ,KAAG;CAEpB,MAAM,cAAc,EAAE,GAAI,iBAAiB,QAAQ,QAAQ,KAAK,OAAO;CACvE,IAAI,OAAO,oBAAoB,CAAC,OAAO,OAAO,aAAa,kBAAkB,GAC3E,YAAY,mBAAmB,OAAO;CACxC,IAAI,aAAa,SAAS;EACxB,MAAM,WAAW,IAAI,IAAI,OAAO,KAAK,WAAW,CAAC,CAAC,KAAK,QAAQ,IAAI,YAAW,CAAE,CAAC;EACjF,MAAM,YAAY,IAAI,IACpB,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,IAAI,YAAW,GAAI,KAAK,CAAC,CAAC;EAE1E,KAAK,MAAM,OAAO,iBAAiB;GACjC,MAAM,QAAQ,UAAU,IAAI,GAAG;GAC/B,IAAI,CAAC,SAAS,IAAI,GAAG,KAAK,UAAU,KAAA,GAAW,YAAY,OAAO;EACpE;CACF;CACA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAErE,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAA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EAAE,KAAK,CAAC,EAAE,OAAO;;AAKxD,qBAAa,gBAAiB,SAAQ,YAAY;IACpC,QAAQ,CAAC,MAAM,EAAE,eAAe;gBAAvB,MAAM,EAAE,eAAe","names":[],"ignoreList":[],"sources":["../src/errors.twill"]}
package/dist/errors.js CHANGED
@@ -1,61 +1,65 @@
1
- export class ProcessError extends Error {
2
- processIdentifier;
3
- terminationStatus;
4
- standardOutput;
5
- standardError;
6
- unresolvedProcessIdentifier;
7
- cleanupErrors = [];
8
- constructor(message, processIdentifier, options) {
9
- super(message, options);
10
- this.name = new.target.name;
11
- this.processIdentifier = processIdentifier;
12
- }
13
- }
14
- export class ProcessLaunchError extends ProcessError {
15
- constructor(cause) {
16
- super('Subprocess could not start', undefined, { cause });
17
- }
18
- }
19
- export class ProcessIOError extends ProcessError {
20
- stream;
21
- constructor(stream, processIdentifier, cause) {
22
- super(`Subprocess ${stream} failed`, processIdentifier, { cause });
23
- this.stream = stream;
24
- }
25
- }
26
- export class ProcessAbortError extends ProcessError {
27
- constructor(processIdentifier, reason) {
28
- super('Subprocess aborted', processIdentifier, { cause: reason });
29
- }
30
- }
31
- export class ProcessTimeoutError extends ProcessError {
32
- timeoutMs;
33
- constructor(timeoutMs, processIdentifier) {
34
- super('Subprocess timed out', processIdentifier);
35
- this.timeoutMs = timeoutMs;
36
- }
37
- }
38
- export class OutputLimitError extends ProcessError {
39
- stream;
40
- limit;
41
- constructor(stream, limit, processIdentifier) {
42
- super(`Subprocess ${stream} exceeded its byte limit`, processIdentifier);
43
- this.stream = stream;
44
- this.limit = limit;
45
- }
46
- }
47
- export class ProcessTeardownError extends ProcessError {
48
- constructor(processIdentifier, cause) {
49
- super('Owned subprocess could not be terminated', processIdentifier, { cause });
50
- Object.assign(this, { unresolvedProcessIdentifier: processIdentifier });
51
- }
52
- }
53
- export class ProcessExitError extends ProcessError {
54
- result;
55
- constructor(result) {
56
- super('Subprocess exited unsuccessfully', result.processIdentifier);
57
- this.result = result;
58
- Object.assign(this, result);
59
- }
60
- }
1
+ //#region src/errors.twill
2
+ var ProcessError = class extends Error {
3
+ processIdentifier;
4
+ terminationStatus;
5
+ standardOutput;
6
+ standardError;
7
+ unresolvedProcessIdentifier;
8
+ cleanupErrors = [];
9
+ constructor(message, processIdentifier, options) {
10
+ super(message, options);
11
+ this.name = new.target.name;
12
+ this.processIdentifier = processIdentifier;
13
+ }
14
+ };
15
+ var ProcessLaunchError = class extends ProcessError {
16
+ constructor(cause) {
17
+ super("Subprocess could not start", void 0, { cause });
18
+ }
19
+ };
20
+ var ProcessIOError = class extends ProcessError {
21
+ stream;
22
+ constructor(stream, processIdentifier, cause) {
23
+ super(`Subprocess ${stream} failed`, processIdentifier, { cause });
24
+ this.stream = stream;
25
+ }
26
+ };
27
+ var ProcessAbortError = class extends ProcessError {
28
+ constructor(processIdentifier, reason) {
29
+ super("Subprocess aborted", processIdentifier, { cause: reason });
30
+ }
31
+ };
32
+ var ProcessTimeoutError = class extends ProcessError {
33
+ timeoutMs;
34
+ constructor(timeoutMs, processIdentifier) {
35
+ super("Subprocess timed out", processIdentifier);
36
+ this.timeoutMs = timeoutMs;
37
+ }
38
+ };
39
+ var OutputLimitError = class extends ProcessError {
40
+ stream;
41
+ limit;
42
+ constructor(stream, limit, processIdentifier) {
43
+ super(`Subprocess ${stream} exceeded its byte limit`, processIdentifier);
44
+ this.stream = stream;
45
+ this.limit = limit;
46
+ }
47
+ };
48
+ var ProcessTeardownError = class extends ProcessError {
49
+ constructor(processIdentifier, cause) {
50
+ super("Owned subprocess could not be terminated", processIdentifier, { cause });
51
+ Object.assign(this, { unresolvedProcessIdentifier: processIdentifier });
52
+ }
53
+ };
54
+ var ProcessExitError = class extends ProcessError {
55
+ result;
56
+ constructor(result) {
57
+ super("Subprocess exited unsuccessfully", result.processIdentifier);
58
+ this.result = result;
59
+ Object.assign(this, result);
60
+ }
61
+ };
62
+ //#endregion
63
+ export { OutputLimitError, ProcessAbortError, ProcessError, ProcessExitError, ProcessIOError, ProcessLaunchError, ProcessTeardownError, ProcessTimeoutError };
64
+
61
65
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,iBAAiB,CAAU;IAC3B,iBAAiB,CAAqB;IACtC,cAAc,CAAmB;IACjC,aAAa,CAAmB;IAChC,2BAA2B,CAAU;IACrC,aAAa,GAAqB,EAAE,CAAC;IAC9C,YAAY,OAAe,EAAE,iBAA0B,EAAE,OAAsB;QAC7E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;CACF;AACD,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAClD,YAAY,KAAc;QACxB,KAAK,CAAC,4BAA4B,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF;AACD,MAAM,OAAO,cAAe,SAAQ,YAAY;IAEnC;IADX,YACW,MAAqC,EAC9C,iBAAqC,EACrC,KAAc;QAEd,KAAK,CAAC,cAAc,MAAM,SAAS,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAJ1D,WAAM,GAAN,MAAM,CAA+B;IAKhD,CAAC;CACF;AACD,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACjD,YAAY,iBAAqC,EAAE,MAAe;QAChE,KAAK,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACpE,CAAC;CACF;AACD,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAExC;IADX,YACW,SAAiB,EAC1B,iBAAqC;QAErC,KAAK,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;QAH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,OAAM,UAAW,mBAAmB,EAAE,MAAK,CAAE;EAJxD,KAAA,SAAA;CAKX;AACF;AACA,IAAa,oBAAb,cAAuC,aAAY;CACjD,YAAY,mBAAuC,QAAe;EAChE,MAAM,sBAAsB,mBAAmB,EAAE,OAAO,OAAM,CAAE;CAClE;AACF;AACA,IAAa,sBAAb,cAAyC,aAAY;CAExC;CADX,YACW,WACT,mBAAqC;EAErC,MAAM,wBAAwB,iBAAiB;EAHtC,KAAA,YAAA;CAIX;AACF;AACA,IAAa,mBAAb,cAAsC,aAAY;CAErC;CACA;CAFX,YACW,QACA,OACT,mBAAqC;EAErC,MAAM,cAAc,OAAM,2BAA4B,iBAAiB;EAJ9D,KAAA,SAAA;EACA,KAAA,QAAA;CAIX;AACF;AACA,IAAa,uBAAb,cAA0C,aAAY;CACpD,YAAY,mBAA2B,OAAe;EACpD,MAAM,4CAA4C,mBAAmB,EAAE,MAAK,CAAE;EAC9E,OAAO,OAAO,MAAM,EAAE,6BAA6B,kBAAiB,CAAE;CACxE;AACF;AACA,IAAa,mBAAb,cAAsC,aAAY;CAC3B;CAArB,YAAqB,QAAuB;EAC1C,MAAM,oCAAoC,OAAO,iBAAiB;EAD/C,KAAA,SAAA;EAEnB,OAAO,OAAO,MAAM,MAAM;CAC5B;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Command, type RunOptions, type OutputPolicy, type OutputValue, type InheritedOutput } from './values.js';
1
+ import { Command, type OutputPolicy, type OutputValue, type RunOptions, type InheritedOutput } from './values.js';
2
2
  export { Command, Environment, Input, Output } from './values.js';
3
3
  export type { OutputPolicy, OutputValue, RunOptions, ProcessInput, InputPolicy, InheritedOutput, DiscardedOutput, TextOutput, ByteOutput, } from './values.js';
4
4
  export { ProcessError, ProcessLaunchError, ProcessAbortError, ProcessTimeoutError, ProcessExitError, ProcessIOError, OutputLimitError, ProcessTeardownError, } from './errors.js';
@@ -17,7 +17,7 @@ export interface ExecutionResult<O extends OutputPolicy = OutputPolicy, E extend
17
17
  }
18
18
  type ExactOptions<O> = O & Record<Exclude<keyof O, keyof RunOptions>, never>;
19
19
  type SelectedOutput<P> = Extract<P, OutputPolicy> | (undefined extends P ? InheritedOutput : never);
20
- declare function run<Options extends RunOptions = RunOptions<InheritedOutput, InheritedOutput>>(command: Command, options?: ExactOptions<Options>): Promise<ExecutionResult<SelectedOutput<Options['output']>, SelectedOutput<Options['error']>>>;
20
+ declare function run<Options extends RunOptions = RunOptions<InheritedOutput, InheritedOutput>>(cmd: Command, options?: ExactOptions<Options>): Promise<ExecutionResult<SelectedOutput<Options['output']>, SelectedOutput<Options['error']>>>;
21
21
  export declare const Subprocess: Readonly<{
22
22
  run: typeof run;
23
23
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EACV,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM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