@push.rocks/smartshell 3.2.4 → 3.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.smartshell.d.ts +70 -2
- package/dist_ts/classes.smartshell.js +595 -24
- package/package.json +1 -1
- package/readme.md +334 -516
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.smartshell.ts +695 -25
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartshell',
|
|
6
|
-
version: '3.
|
|
6
|
+
version: '3.3.0',
|
|
7
7
|
description: 'A library for executing shell commands using promises.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHdEQUF3RDtDQUN0RSxDQUFBIn0=
|
|
@@ -5,6 +5,14 @@ import * as cp from 'child_process';
|
|
|
5
5
|
export interface IExecResult {
|
|
6
6
|
exitCode: number;
|
|
7
7
|
stdout: string;
|
|
8
|
+
signal?: NodeJS.Signals;
|
|
9
|
+
stderr?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IExecResultInteractive extends IExecResult {
|
|
12
|
+
sendInput: (input: string) => Promise<void>;
|
|
13
|
+
sendLine: (line: string) => Promise<void>;
|
|
14
|
+
endInput: () => void;
|
|
15
|
+
finalPromise: Promise<IExecResult>;
|
|
8
16
|
}
|
|
9
17
|
export interface IExecResultStreaming {
|
|
10
18
|
childProcess: cp.ChildProcess;
|
|
@@ -13,6 +21,33 @@ export interface IExecResultStreaming {
|
|
|
13
21
|
terminate: () => Promise<void>;
|
|
14
22
|
keyboardInterrupt: () => Promise<void>;
|
|
15
23
|
customSignal: (signal: plugins.smartexit.TProcessSignal) => Promise<void>;
|
|
24
|
+
sendInput: (input: string) => Promise<void>;
|
|
25
|
+
sendLine: (line: string) => Promise<void>;
|
|
26
|
+
endInput: () => void;
|
|
27
|
+
}
|
|
28
|
+
interface IExecOptions {
|
|
29
|
+
commandString: string;
|
|
30
|
+
silent?: boolean;
|
|
31
|
+
strict?: boolean;
|
|
32
|
+
streaming?: boolean;
|
|
33
|
+
interactive?: boolean;
|
|
34
|
+
passthrough?: boolean;
|
|
35
|
+
interactiveControl?: boolean;
|
|
36
|
+
usePty?: boolean;
|
|
37
|
+
ptyCols?: number;
|
|
38
|
+
ptyRows?: number;
|
|
39
|
+
ptyTerm?: string;
|
|
40
|
+
ptyShell?: string;
|
|
41
|
+
maxBuffer?: number;
|
|
42
|
+
onData?: (chunk: Buffer | string) => void;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
debug?: boolean;
|
|
45
|
+
env?: NodeJS.ProcessEnv;
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
export interface ISpawnOptions extends Omit<IExecOptions, 'commandString'> {
|
|
49
|
+
command: string;
|
|
50
|
+
args?: string[];
|
|
16
51
|
}
|
|
17
52
|
export declare class Smartshell {
|
|
18
53
|
shellEnv: ShellEnv;
|
|
@@ -26,6 +61,10 @@ export declare class Smartshell {
|
|
|
26
61
|
* Executes an interactive command.
|
|
27
62
|
*/
|
|
28
63
|
private _execInteractive;
|
|
64
|
+
/**
|
|
65
|
+
* Executes a command with args array (shell:false) for security
|
|
66
|
+
*/
|
|
67
|
+
private _execSpawn;
|
|
29
68
|
/**
|
|
30
69
|
* Executes a command and returns either a non-streaming result or a streaming interface.
|
|
31
70
|
*/
|
|
@@ -37,6 +76,35 @@ export declare class Smartshell {
|
|
|
37
76
|
execStreaming(commandString: string, silent?: boolean): Promise<IExecResultStreaming>;
|
|
38
77
|
execStreamingSilent(commandString: string): Promise<IExecResultStreaming>;
|
|
39
78
|
execInteractive(commandString: string): Promise<void>;
|
|
40
|
-
|
|
41
|
-
|
|
79
|
+
execPassthrough(commandString: string): Promise<IExecResult>;
|
|
80
|
+
execStreamingPassthrough(commandString: string): Promise<IExecResultStreaming>;
|
|
81
|
+
execInteractiveControl(commandString: string): Promise<IExecResultInteractive>;
|
|
82
|
+
execStreamingInteractiveControl(commandString: string): Promise<IExecResultStreaming>;
|
|
83
|
+
execInteractiveControlPty(commandString: string): Promise<IExecResultInteractive>;
|
|
84
|
+
execStreamingInteractiveControlPty(commandString: string): Promise<IExecResultStreaming>;
|
|
85
|
+
/**
|
|
86
|
+
* Executes a command with args array (shell:false) for security
|
|
87
|
+
* This is the recommended API for untrusted input
|
|
88
|
+
*/
|
|
89
|
+
execSpawn(command: string, args?: string[], options?: Omit<ISpawnOptions, 'command' | 'args'>): Promise<IExecResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Executes a command with args array in streaming mode
|
|
92
|
+
*/
|
|
93
|
+
execSpawnStreaming(command: string, args?: string[], options?: Omit<ISpawnOptions, 'command' | 'args' | 'streaming'>): Promise<IExecResultStreaming>;
|
|
94
|
+
/**
|
|
95
|
+
* Executes a command with args array with interactive control
|
|
96
|
+
*/
|
|
97
|
+
execSpawnInteractiveControl(command: string, args?: string[], options?: Omit<ISpawnOptions, 'command' | 'args' | 'interactiveControl'>): Promise<IExecResultInteractive>;
|
|
98
|
+
execAndWaitForLine(commandString: string, regex: RegExp, silent?: boolean, options?: {
|
|
99
|
+
timeout?: number;
|
|
100
|
+
terminateOnMatch?: boolean;
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
execAndWaitForLineSilent(commandString: string, regex: RegExp, options?: {
|
|
103
|
+
timeout?: number;
|
|
104
|
+
terminateOnMatch?: boolean;
|
|
105
|
+
}): Promise<void>;
|
|
106
|
+
private nodePty;
|
|
107
|
+
private lazyLoadNodePty;
|
|
108
|
+
private _execCommandPty;
|
|
42
109
|
}
|
|
110
|
+
export {};
|