@fuzdev/fuz_util 0.46.0 → 0.48.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/args.d.ts +138 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +447 -0
- package/dist/process.d.ts +4 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +8 -6
- package/dist/source_json.d.ts +8 -8
- package/package.json +6 -6
- package/src/lib/args.ts +546 -0
- package/src/lib/process.ts +12 -6
package/src/lib/process.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface SpawnResultError {
|
|
|
24
24
|
ok: false;
|
|
25
25
|
child: ChildProcess;
|
|
26
26
|
error: Error;
|
|
27
|
+
code: null;
|
|
28
|
+
signal: null;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -33,6 +35,7 @@ export interface SpawnResultError {
|
|
|
33
35
|
export interface SpawnResultExited {
|
|
34
36
|
ok: boolean;
|
|
35
37
|
child: ChildProcess;
|
|
38
|
+
error: null;
|
|
36
39
|
code: number;
|
|
37
40
|
signal: null;
|
|
38
41
|
}
|
|
@@ -43,6 +46,7 @@ export interface SpawnResultExited {
|
|
|
43
46
|
export interface SpawnResultSignaled {
|
|
44
47
|
ok: false;
|
|
45
48
|
child: ChildProcess;
|
|
49
|
+
error: null;
|
|
46
50
|
code: null;
|
|
47
51
|
signal: NodeJS.Signals;
|
|
48
52
|
}
|
|
@@ -62,19 +66,19 @@ export type SpawnResult = SpawnResultError | SpawnResultExited | SpawnResultSign
|
|
|
62
66
|
* Type guard for spawn errors (process failed to start).
|
|
63
67
|
*/
|
|
64
68
|
export const spawn_result_is_error = (result: SpawnResult): result is SpawnResultError =>
|
|
65
|
-
|
|
69
|
+
result.error !== null;
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
72
|
* Type guard for signal termination.
|
|
69
73
|
*/
|
|
70
74
|
export const spawn_result_is_signaled = (result: SpawnResult): result is SpawnResultSignaled =>
|
|
71
|
-
|
|
75
|
+
result.signal !== null;
|
|
72
76
|
|
|
73
77
|
/**
|
|
74
78
|
* Type guard for normal exit with code.
|
|
75
79
|
*/
|
|
76
80
|
export const spawn_result_is_exited = (result: SpawnResult): result is SpawnResultExited =>
|
|
77
|
-
|
|
81
|
+
result.code !== null;
|
|
78
82
|
|
|
79
83
|
//
|
|
80
84
|
// Spawn Options
|
|
@@ -156,16 +160,16 @@ const create_closed_promise = (child: ChildProcess): Promise<SpawnResult> => {
|
|
|
156
160
|
child.once('error', (err) => {
|
|
157
161
|
if (resolved) return;
|
|
158
162
|
resolved = true;
|
|
159
|
-
resolve({ok: false, child, error: err});
|
|
163
|
+
resolve({ok: false, child, error: err, code: null, signal: null});
|
|
160
164
|
});
|
|
161
165
|
|
|
162
166
|
child.once('close', (code, signal) => {
|
|
163
167
|
if (resolved) return;
|
|
164
168
|
resolved = true;
|
|
165
169
|
if (signal !== null) {
|
|
166
|
-
resolve({ok: false, child, code: null, signal});
|
|
170
|
+
resolve({ok: false, child, error: null, code: null, signal});
|
|
167
171
|
} else {
|
|
168
|
-
resolve({ok: code === 0, child, code: code ?? 0, signal: null});
|
|
172
|
+
resolve({ok: code === 0, child, error: null, code: code ?? 0, signal: null});
|
|
169
173
|
}
|
|
170
174
|
});
|
|
171
175
|
|
|
@@ -332,6 +336,7 @@ export class ProcessRegistry {
|
|
|
332
336
|
return {
|
|
333
337
|
ok: child.exitCode === 0,
|
|
334
338
|
child,
|
|
339
|
+
error: null,
|
|
335
340
|
code: child.exitCode,
|
|
336
341
|
signal: null,
|
|
337
342
|
};
|
|
@@ -341,6 +346,7 @@ export class ProcessRegistry {
|
|
|
341
346
|
return {
|
|
342
347
|
ok: false,
|
|
343
348
|
child,
|
|
349
|
+
error: null,
|
|
344
350
|
code: null,
|
|
345
351
|
signal: child.signalCode,
|
|
346
352
|
};
|