@nu-art/commando 0.204.27 → 0.204.28
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.d.ts +1 -0
- package/console/ConsoleScreen.js +7 -0
- package/core/cli.d.ts +9 -0
- package/core/cli.js +30 -1
- package/package.json +1 -1
package/console/ConsoleScreen.js
CHANGED
|
@@ -66,6 +66,13 @@ class ConsoleScreen extends ts_common_1.Logger {
|
|
|
66
66
|
this.pause();
|
|
67
67
|
return this;
|
|
68
68
|
};
|
|
69
|
+
this.releaseScreen = () => {
|
|
70
|
+
if (!this.screen)
|
|
71
|
+
return;
|
|
72
|
+
this.screen.detach();
|
|
73
|
+
this.screen.clear();
|
|
74
|
+
this.screen.destroy();
|
|
75
|
+
};
|
|
69
76
|
this.screenProps = props;
|
|
70
77
|
}
|
|
71
78
|
setState(state) {
|
package/core/cli.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="mocha" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
7
|
+
/// <reference types="node" />
|
|
3
8
|
import { ExecOptions } from 'child_process';
|
|
4
9
|
import { Constructor, Logger } from '@nu-art/ts-common';
|
|
5
10
|
export type CliBlock<Cli extends CliWrapper> = (cli: Cli) => void;
|
|
@@ -41,6 +46,8 @@ export declare class CliInteractive extends BaseCLI {
|
|
|
41
46
|
constructor();
|
|
42
47
|
execute: () => Promise<void>;
|
|
43
48
|
endInteractive: () => void;
|
|
49
|
+
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
50
|
+
gracefullyKill: () => Promise<void>;
|
|
44
51
|
}
|
|
45
52
|
export declare class Cli extends BaseCLI {
|
|
46
53
|
private cliOptions;
|
|
@@ -98,5 +105,7 @@ export declare class CommandoInteractive {
|
|
|
98
105
|
static create<T extends Constructor<CliWrapper>[]>(...plugins: T): CommandoInteractive & Commando & import("./class-merger").MergeTypes<T>;
|
|
99
106
|
setUID: (uid: string) => this;
|
|
100
107
|
close: () => this;
|
|
108
|
+
kill: (signal?: NodeJS.Signals | number) => boolean;
|
|
109
|
+
gracefullyKill: () => Promise<void>;
|
|
101
110
|
}
|
|
102
111
|
export {};
|
package/core/cli.js
CHANGED
|
@@ -70,7 +70,25 @@ class CliInteractive extends BaseCLI {
|
|
|
70
70
|
this.endInteractive = () => {
|
|
71
71
|
this.shell.stdin.end();
|
|
72
72
|
};
|
|
73
|
-
this.
|
|
73
|
+
this.kill = (signal) => {
|
|
74
|
+
return this.shell.kill(signal);
|
|
75
|
+
};
|
|
76
|
+
this.gracefullyKill = async () => {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
console.log('Killing process');
|
|
79
|
+
this.shell.on('exit', (code, signal) => {
|
|
80
|
+
console.log('Process Killed');
|
|
81
|
+
resolve();
|
|
82
|
+
});
|
|
83
|
+
if (!this.shell.pid)
|
|
84
|
+
this.shell.kill('SIGINT');
|
|
85
|
+
else
|
|
86
|
+
process.kill(-this.shell.pid, 'SIGINT');
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
this.shell = (0, node_child_process_1.spawn)('/bin/bash', {
|
|
90
|
+
// detached:true,
|
|
91
|
+
});
|
|
74
92
|
// Handle shell output (stdout)
|
|
75
93
|
const printer = (data) => {
|
|
76
94
|
const message = data.toString().trim();
|
|
@@ -202,6 +220,10 @@ class CommandoInteractive {
|
|
|
202
220
|
constructor() {
|
|
203
221
|
this.setUID = (uid) => this;
|
|
204
222
|
this.close = () => this;
|
|
223
|
+
this.kill = (signal) => true;
|
|
224
|
+
this.gracefullyKill = () => {
|
|
225
|
+
return new Promise(resolve => resolve());
|
|
226
|
+
};
|
|
205
227
|
}
|
|
206
228
|
static create(...plugins) {
|
|
207
229
|
const _commando = Commando.create(...plugins);
|
|
@@ -216,6 +238,13 @@ class CommandoInteractive {
|
|
|
216
238
|
commando.close = () => {
|
|
217
239
|
return commando;
|
|
218
240
|
};
|
|
241
|
+
commando.kill = (signal) => {
|
|
242
|
+
return commando.cli.kill(signal);
|
|
243
|
+
};
|
|
244
|
+
commando.gracefullyKill = () => {
|
|
245
|
+
console.log('Commando Inter calling gracefullyKill');
|
|
246
|
+
return commando.cli.gracefullyKill();
|
|
247
|
+
};
|
|
219
248
|
return commando;
|
|
220
249
|
}
|
|
221
250
|
}
|