@sorrell/cli-utilities 1.0.39 → 1.0.41
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/Distribution/PseudoTerminal/PseudoTerminal.Types.d.ts +14 -1
- package/Distribution/PseudoTerminal/PseudoTerminal.Types.d.ts.map +1 -1
- package/Distribution/PseudoTerminal/PseudoTerminal.d.ts +19 -2
- package/Distribution/PseudoTerminal/PseudoTerminal.d.ts.map +1 -1
- package/Distribution/PseudoTerminal/PseudoTerminal.js +29 -2
- package/Distribution/PseudoTerminal/PseudoTerminal.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,5 +4,18 @@
|
|
|
4
4
|
* @copyright (c) 2026 Gage Sorrell
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import type { IPty as IPtyOriginal } from "node-pty";
|
|
8
|
+
/**
|
|
9
|
+
* The data that is supplied to the listener argument of
|
|
10
|
+
* {@link IPtyOriginal!onExit | onExit}.
|
|
11
|
+
*/
|
|
12
|
+
export type OnExitData = Parameters<Parameters<IPty["onExit"]>[0]>[0];
|
|
13
|
+
/**
|
|
14
|
+
* The {@link IPtyOriginal | IPty}, with an additional {@link Promise}
|
|
15
|
+
* {@link OnExit}, which resolves to the {@link OnExitData} for the
|
|
16
|
+
* given session.
|
|
17
|
+
*/
|
|
18
|
+
export interface IPty extends IPtyOriginal {
|
|
19
|
+
OnExit: Promise<OnExitData>;
|
|
20
|
+
}
|
|
8
21
|
//# sourceMappingURL=PseudoTerminal.Types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PseudoTerminal.Types.d.ts","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.Types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
1
|
+
{"version":3,"file":"PseudoTerminal.Types.d.ts","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.Types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,UAAU,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,WAAW,IAAK,SAAQ,YAAY;IAEtC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CAC/B"}
|
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
* @copyright (c) 2026 Gage Sorrell
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import type { IPty } from "./PseudoTerminal.Types.js";
|
|
8
|
+
import { type IPtyForkOptions, type IWindowsPtyForkOptions } from "node-pty";
|
|
9
|
+
/**
|
|
10
|
+
* This function wraps {@link spawn} and provides sensible default options.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} Command - The name of the command to run.
|
|
13
|
+
* @param {Array<string>} Arguments - The arguments to supply with the {@link Command}.
|
|
14
|
+
* @param {IPtyForkOptions | IWindowsPtyForkOptions} Options - The options for the resulting
|
|
15
|
+
* `node-pty` session.
|
|
16
|
+
*
|
|
17
|
+
* @returns {IPty} The session
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* Running `npm install @sorrell/cli-utilities` via a `node-pty` session,
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const MySession: IPty = Spawn("npm", [ "install" ]);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function Spawn(Command: string, Arguments?: Array<string>, Options?: IPtyForkOptions | IWindowsPtyForkOptions): IPty;
|
|
9
26
|
//# sourceMappingURL=PseudoTerminal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PseudoTerminal.d.ts","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"PseudoTerminal.d.ts","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,2BAA2B,CAAC;AAClE,OAAO,EACH,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EACpB,MAAM,UAAU,CAAC;AAI5B;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CACjB,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,KAAK,CAAC,MAAM,CAAO,EAC9B,OAAO,GAAE,eAAe,GAAG,sBAA4B,GACxD,IAAI,CA0CN"}
|
|
@@ -6,7 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { spawn } from "node-pty";
|
|
8
8
|
import { GetCommandName } from "../Command/Command.js";
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* This function wraps {@link spawn} and provides sensible default options.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} Command - The name of the command to run.
|
|
13
|
+
* @param {Array<string>} Arguments - The arguments to supply with the {@link Command}.
|
|
14
|
+
* @param {IPtyForkOptions | IWindowsPtyForkOptions} Options - The options for the resulting
|
|
15
|
+
* `node-pty` session.
|
|
16
|
+
*
|
|
17
|
+
* @returns {IPty} The session
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* Running `npm install @sorrell/cli-utilities` via a `node-pty` session,
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const MySession: IPty = Spawn("npm", [ "install" ]);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function Spawn(Command, Arguments = [], Options = {}) {
|
|
10
26
|
const DefaultOptions = {
|
|
11
27
|
cols: process.stdout.columns || 80,
|
|
12
28
|
cwd: process.cwd(),
|
|
@@ -18,6 +34,17 @@ export function Spawn(Command, Arguments, Options) {
|
|
|
18
34
|
...DefaultOptions,
|
|
19
35
|
...Options
|
|
20
36
|
};
|
|
21
|
-
|
|
37
|
+
const Out = spawn(GetCommandName(Command), Arguments, OutOptions);
|
|
38
|
+
let OnExitResolve;
|
|
39
|
+
const OnExit = new Promise((Resolve, _Reject) => {
|
|
40
|
+
OnExitResolve = Resolve;
|
|
41
|
+
});
|
|
42
|
+
Out.onExit((Data) => {
|
|
43
|
+
OnExitResolve(Data);
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
...Out,
|
|
47
|
+
OnExit
|
|
48
|
+
};
|
|
22
49
|
}
|
|
23
50
|
//# sourceMappingURL=PseudoTerminal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PseudoTerminal.js","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"PseudoTerminal.js","sourceRoot":"","sources":["../../Source/PseudoTerminal/PseudoTerminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAIH,KAAK,EAAE,MAAM,UAAU,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,KAAK,CACjB,OAAe,EACf,YAA2B,EAAG,EAC9B,UAAoD,EAAG;IAGvD,MAAM,cAAc,GAChB;QACI,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE;QAClC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,GAAG,EAAE,OAAO,CAAC,GAA6B;QAC1C,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE;KAClC,CAAC;IAEN,MAAM,UAAU,GACZ;QACI,GAAG,cAAc;QACjB,GAAG,OAAO;KACb,CAAC;IAEN,MAAM,GAAG,GAAiB,KAAK,CAC3B,cAAc,CAAC,OAAO,CAAC,EACvB,SAAS,EACT,UAAU,CACb,CAAC;IAEF,IAAI,aAAmC,CAAC;IAExC,MAAM,MAAM,GAAmB,IAAI,OAAO,CAAa,CACnD,OAA6B,EAC7B,OAAgB,EACZ,EAAE;QAEN,aAAa,GAAG,OAAO,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,CAAC,IAAgB,EAAQ,EAAE;QAElC,aAAa,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,GAAG,GAAG;QACN,MAAM;KACT,CAAC;AACN,CAAC"}
|