@nu-art/commando 0.204.30 → 0.204.32
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/console/ConsoleScreen.js +0 -1
- package/core/cli.d.ts +4 -4
- package/core/cli.js +6 -6
- package/package.json +1 -1
package/console/ConsoleScreen.js
CHANGED
package/core/cli.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/// <reference types="node" />
|
|
7
7
|
/// <reference types="node" />
|
|
8
8
|
import { ExecOptions } from 'child_process';
|
|
9
|
-
import { Constructor, Logger } from '@nu-art/ts-common';
|
|
9
|
+
import { AsyncVoidFunction, Constructor, Logger } from '@nu-art/ts-common';
|
|
10
10
|
export type CliBlock<Cli extends CliWrapper> = (cli: Cli) => void;
|
|
11
11
|
export type CliOptions = ExecOptions & {
|
|
12
12
|
encoding: BufferEncoding | string | null;
|
|
@@ -51,9 +51,9 @@ export declare class CliInteractive extends BaseCLI {
|
|
|
51
51
|
private shell;
|
|
52
52
|
constructor();
|
|
53
53
|
execute: () => Promise<void>;
|
|
54
|
-
endInteractive: () => void;
|
|
54
|
+
endInteractive: (cb?: AsyncVoidFunction) => void;
|
|
55
55
|
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
56
|
-
gracefullyKill: (pid?: number) => Promise<
|
|
56
|
+
gracefullyKill: (pid?: number) => Promise<void>;
|
|
57
57
|
}
|
|
58
58
|
export declare class Cli extends BaseCLI {
|
|
59
59
|
private cliOptions;
|
|
@@ -118,7 +118,7 @@ export declare class CommandoInteractive {
|
|
|
118
118
|
removeStdoutProcessor: (processor: (stdout: string) => void) => this;
|
|
119
119
|
removeStderrProcessor: (processor: (stderr: string) => void) => this;
|
|
120
120
|
setUID: (uid: string) => this;
|
|
121
|
-
close: () => this;
|
|
121
|
+
close: (cb?: AsyncVoidFunction) => this;
|
|
122
122
|
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
123
123
|
gracefullyKill: (pid?: number) => Promise<void>;
|
|
124
124
|
}
|
package/core/cli.js
CHANGED
|
@@ -83,9 +83,9 @@ class CliInteractive extends BaseCLI {
|
|
|
83
83
|
});
|
|
84
84
|
this.commands = [];
|
|
85
85
|
};
|
|
86
|
-
this.endInteractive = () => {
|
|
86
|
+
this.endInteractive = (cb) => {
|
|
87
87
|
var _a;
|
|
88
|
-
(_a = this.shell.stdin) === null || _a === void 0 ? void 0 : _a.end();
|
|
88
|
+
(_a = this.shell.stdin) === null || _a === void 0 ? void 0 : _a.end(cb);
|
|
89
89
|
};
|
|
90
90
|
this.kill = (signal) => {
|
|
91
91
|
return this.shell.kill(signal);
|
|
@@ -95,7 +95,6 @@ class CliInteractive extends BaseCLI {
|
|
|
95
95
|
console.log('Killing process');
|
|
96
96
|
this.shell.on('exit', async (code, signal) => {
|
|
97
97
|
console.log(`Process Killed ${signal}`);
|
|
98
|
-
await (0, ts_common_1.sleep)(5000);
|
|
99
98
|
resolve();
|
|
100
99
|
});
|
|
101
100
|
if (pid) {
|
|
@@ -106,7 +105,7 @@ class CliInteractive extends BaseCLI {
|
|
|
106
105
|
console.log(`KILLING SHELL WITH SIGINT`);
|
|
107
106
|
this.shell.kill('SIGINT');
|
|
108
107
|
}
|
|
109
|
-
})
|
|
108
|
+
});
|
|
110
109
|
};
|
|
111
110
|
this.shell = (0, node_child_process_1.spawn)('/bin/bash', {
|
|
112
111
|
detached: true,
|
|
@@ -272,7 +271,7 @@ class CommandoInteractive {
|
|
|
272
271
|
this.removeStdoutProcessor = (processor) => this;
|
|
273
272
|
this.removeStderrProcessor = (processor) => this;
|
|
274
273
|
this.setUID = (uid) => this;
|
|
275
|
-
this.close = () => this;
|
|
274
|
+
this.close = (cb) => this;
|
|
276
275
|
this.kill = (signal) => true;
|
|
277
276
|
this.gracefullyKill = (pid) => {
|
|
278
277
|
return new Promise(resolve => resolve());
|
|
@@ -288,7 +287,8 @@ class CommandoInteractive {
|
|
|
288
287
|
commando.cli.setUID(uid);
|
|
289
288
|
return commando;
|
|
290
289
|
};
|
|
291
|
-
commando.close = () => {
|
|
290
|
+
commando.close = (cb) => {
|
|
291
|
+
commando.cli.endInteractive(cb);
|
|
292
292
|
return commando;
|
|
293
293
|
};
|
|
294
294
|
commando.kill = (signal) => {
|