topkat-utils 1.2.68 → 1.2.69
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/backend.ts +5 -2
- package/dist/backend.d.ts +2 -0
- package/dist/backend.js +3 -1
- package/dist/backend.js.map +1 -1
- package/package.json +1 -1
package/backend.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
import { C } from './src/logger-utils'
|
|
4
|
-
import { exec } from 'child_process'
|
|
4
|
+
import { exec, ChildProcess } from 'child_process'
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/** Execute a custom command into a child terminal and wait for process completion */
|
|
@@ -22,13 +22,15 @@ export async function execWaitForOutput(
|
|
|
22
22
|
streamConsoleOutput: (outputStr: string) => any,
|
|
23
23
|
/** see nodeJs exec() command options */
|
|
24
24
|
execOptions: { cwd?: string, [seeNodeJsDocOnExec: string]: any }
|
|
25
|
+
|
|
26
|
+
onStartProcess(process: ChildProcess): any
|
|
25
27
|
}>
|
|
26
28
|
): Promise<string | undefined> {
|
|
27
29
|
|
|
28
30
|
let outputStream = ''
|
|
29
31
|
let execOptions
|
|
30
32
|
|
|
31
|
-
const { nbSecondsBeforeKillingProcess = 20, streamConsoleOutput = () => true, errorHandle = 'throw', logOutputStream = true, stringOrRegexpToSearchForConsideringDone, keyCodeToSend = {} } = config
|
|
33
|
+
const { nbSecondsBeforeKillingProcess = 20, streamConsoleOutput = () => true, errorHandle = 'throw', logOutputStream = true, stringOrRegexpToSearchForConsideringDone, keyCodeToSend = {}, onStartProcess } = config
|
|
32
34
|
|
|
33
35
|
try {
|
|
34
36
|
return await new Promise((res, reject) => {
|
|
@@ -38,6 +40,7 @@ export async function execWaitForOutput(
|
|
|
38
40
|
}, nbSecondsBeforeKillingProcess * 1000) : undefined
|
|
39
41
|
|
|
40
42
|
const process2 = exec(command, execOptions)
|
|
43
|
+
if (onStartProcess) onStartProcess(process2)
|
|
41
44
|
const resolve = () => {
|
|
42
45
|
process2?.kill('SIGINT')
|
|
43
46
|
clearTimeout(to)
|
package/dist/backend.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ChildProcess } from 'child_process';
|
|
1
2
|
/** Execute a custom command into a child terminal and wait for process completion */
|
|
2
3
|
export declare function execWaitForOutput(command: string, config?: Partial<{
|
|
3
4
|
/** Whenever to log output to the console, choose false to execute the process silently. Default: true */
|
|
@@ -19,4 +20,5 @@ export declare function execWaitForOutput(command: string, config?: Partial<{
|
|
|
19
20
|
[seeNodeJsDocOnExec: string]: any;
|
|
20
21
|
cwd?: string | undefined;
|
|
21
22
|
};
|
|
23
|
+
onStartProcess(process: ChildProcess): any;
|
|
22
24
|
}>): Promise<string | undefined>;
|
package/dist/backend.js
CHANGED
|
@@ -7,7 +7,7 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
async function execWaitForOutput(command, config = {}) {
|
|
8
8
|
let outputStream = '';
|
|
9
9
|
let execOptions;
|
|
10
|
-
const { nbSecondsBeforeKillingProcess = 20, streamConsoleOutput = () => true, errorHandle = 'throw', logOutputStream = true, stringOrRegexpToSearchForConsideringDone, keyCodeToSend = {} } = config;
|
|
10
|
+
const { nbSecondsBeforeKillingProcess = 20, streamConsoleOutput = () => true, errorHandle = 'throw', logOutputStream = true, stringOrRegexpToSearchForConsideringDone, keyCodeToSend = {}, onStartProcess } = config;
|
|
11
11
|
try {
|
|
12
12
|
return await new Promise((res, reject) => {
|
|
13
13
|
var _a, _b;
|
|
@@ -16,6 +16,8 @@ async function execWaitForOutput(command, config = {}) {
|
|
|
16
16
|
reject(`Exec timeout for ${command}`);
|
|
17
17
|
}, nbSecondsBeforeKillingProcess * 1000) : undefined;
|
|
18
18
|
const process2 = (0, child_process_1.exec)(command, execOptions);
|
|
19
|
+
if (onStartProcess)
|
|
20
|
+
onStartProcess(process2);
|
|
19
21
|
const resolve = () => {
|
|
20
22
|
process2 === null || process2 === void 0 ? void 0 : process2.kill('SIGINT');
|
|
21
23
|
clearTimeout(to);
|
package/dist/backend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../backend.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"backend.js","sourceRoot":"","sources":["../backend.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AACtC,iDAAkD;AAGlD,qFAAqF;AAC9E,KAAK,UAAU,iBAAiB,CACnC,OAAe,EACf,SAAS,EAiBP;IAGF,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI,WAAW,CAAA;IAEf,MAAM,EAAE,6BAA6B,GAAG,EAAE,EAAE,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,EAAE,eAAe,GAAG,IAAI,EAAE,wCAAwC,EAAE,aAAa,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,MAAM,CAAA;IAEpN,IAAI;QACA,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;;YACrC,MAAM,EAAE,GAAG,6BAA6B,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE;gBAC3D,gBAAC,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;gBACtC,MAAM,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC,EAAE,6BAA6B,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YAEpD,MAAM,QAAQ,GAAG,IAAA,oBAAI,EAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAC3C,IAAI,cAAc;gBAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;YAC5C,MAAM,OAAO,GAAG,GAAG,EAAE;gBACjB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;gBACx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