codify-plugin-lib 1.0.27 → 1.0.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/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +4 -3
- package/package.json +1 -1
- package/src/utils/utils.ts +7 -4
package/dist/utils/utils.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type CodifySpawnOptions = {
|
|
|
12
12
|
cwd?: string;
|
|
13
13
|
stdioString?: boolean;
|
|
14
14
|
} & SpawnOptions;
|
|
15
|
-
export declare function codifySpawn(cmd: string, args?: string[], opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString'
|
|
15
|
+
export declare function codifySpawn(cmd: string, args?: string[], opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString'> & {
|
|
16
16
|
throws?: boolean;
|
|
17
17
|
}, extras?: Record<any, any>): Promise<SpawnResult>;
|
|
18
18
|
export declare function isDebug(): boolean;
|
package/dist/utils/utils.js
CHANGED
|
@@ -12,7 +12,7 @@ var SpawnStatus;
|
|
|
12
12
|
})(SpawnStatus || (exports.SpawnStatus = SpawnStatus = {}));
|
|
13
13
|
async function codifySpawn(cmd, args, opts, extras) {
|
|
14
14
|
try {
|
|
15
|
-
const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio: 'pipe', stdioString: true, shell:
|
|
15
|
+
const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio: 'pipe', stdioString: true, shell: opts?.shell ?? process.env.SHELL }, extras);
|
|
16
16
|
if (isDebug()) {
|
|
17
17
|
console.log(`codifySpawn result for: ${cmd}`);
|
|
18
18
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -26,10 +26,11 @@ async function codifySpawn(cmd, args, opts, extras) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
|
|
29
|
+
const shouldThrow = opts?.throws ?? true;
|
|
30
|
+
if (isDebug() || shouldThrow) {
|
|
30
31
|
console.error(`CodifySpawn Error for command ${cmd} ${args}`, error);
|
|
31
32
|
}
|
|
32
|
-
if (
|
|
33
|
+
if (shouldThrow) {
|
|
33
34
|
throw error;
|
|
34
35
|
}
|
|
35
36
|
return {
|
package/package.json
CHANGED
package/src/utils/utils.ts
CHANGED
|
@@ -32,14 +32,16 @@ type CodifySpawnOptions = {
|
|
|
32
32
|
export async function codifySpawn(
|
|
33
33
|
cmd: string,
|
|
34
34
|
args?: string[],
|
|
35
|
-
opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString'
|
|
35
|
+
opts?: Omit<CodifySpawnOptions, 'stdio' | 'stdioString'> & { throws?: boolean },
|
|
36
36
|
extras?: Record<any, any>,
|
|
37
37
|
): Promise<SpawnResult> {
|
|
38
38
|
try {
|
|
39
|
+
// TODO: Need to benchmark the effects of using sh vs zsh for shell.
|
|
40
|
+
// Seems like zsh shells run slower
|
|
39
41
|
const result = await promiseSpawn(
|
|
40
42
|
cmd,
|
|
41
43
|
args ?? [],
|
|
42
|
-
{ ...opts, stdio: 'pipe', stdioString: true, shell:
|
|
44
|
+
{ ...opts, stdio: 'pipe', stdioString: true, shell: opts?.shell ?? process.env.SHELL },
|
|
43
45
|
extras,
|
|
44
46
|
);
|
|
45
47
|
|
|
@@ -57,11 +59,12 @@ export async function codifySpawn(
|
|
|
57
59
|
data: status === SpawnStatus.SUCCESS ? result.stdout : result.stderr
|
|
58
60
|
}
|
|
59
61
|
} catch (error) {
|
|
60
|
-
|
|
62
|
+
const shouldThrow = opts?.throws ?? true;
|
|
63
|
+
if (isDebug() || shouldThrow) {
|
|
61
64
|
console.error(`CodifySpawn Error for command ${cmd} ${args}`, error);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
if (
|
|
67
|
+
if (shouldThrow) {
|
|
65
68
|
throw error;
|
|
66
69
|
}
|
|
67
70
|
|