codify-plugin-lib 1.0.16 → 1.0.18
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 +2 -2
- package/dist/utils/utils.js +7 -4
- package/package.json +1 -1
- package/src/utils/utils.ts +10 -6
package/dist/utils/utils.d.ts
CHANGED
package/dist/utils/utils.js
CHANGED
|
@@ -7,13 +7,16 @@ exports.isDebug = exports.codifySpawn = exports.SpawnStatus = void 0;
|
|
|
7
7
|
const promise_spawn_1 = __importDefault(require("@npmcli/promise-spawn"));
|
|
8
8
|
var SpawnStatus;
|
|
9
9
|
(function (SpawnStatus) {
|
|
10
|
-
SpawnStatus[
|
|
11
|
-
SpawnStatus[
|
|
10
|
+
SpawnStatus["SUCCESS"] = "success";
|
|
11
|
+
SpawnStatus["ERROR"] = "error";
|
|
12
12
|
})(SpawnStatus || (exports.SpawnStatus = SpawnStatus = {}));
|
|
13
13
|
async function codifySpawn(cmd, args, opts, extras) {
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio: 'pipe', stdioString: true, shell: true }, extras);
|
|
16
|
+
if (isDebug()) {
|
|
17
|
+
console.log(`codifySpawn result for: ${cmd}`);
|
|
18
|
+
console.log(JSON.stringify(result, null, 2));
|
|
19
|
+
}
|
|
17
20
|
const status = (result.code === 0 && !result.stderr)
|
|
18
21
|
? SpawnStatus.SUCCESS
|
|
19
22
|
: SpawnStatus.ERROR;
|
package/package.json
CHANGED
package/src/utils/utils.ts
CHANGED
|
@@ -2,8 +2,8 @@ import promiseSpawn from '@npmcli/promise-spawn';
|
|
|
2
2
|
import { SpawnOptions } from 'child_process';
|
|
3
3
|
|
|
4
4
|
export enum SpawnStatus {
|
|
5
|
-
SUCCESS,
|
|
6
|
-
ERROR,
|
|
5
|
+
SUCCESS = 'success',
|
|
6
|
+
ERROR = 'error',
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface SpawnResult {
|
|
@@ -23,14 +23,18 @@ export async function codifySpawn(
|
|
|
23
23
|
extras?: Record<any, any>,
|
|
24
24
|
): Promise<SpawnResult> {
|
|
25
25
|
try {
|
|
26
|
-
const stdio = isDebug() ? 'inherit' : 'pipe';
|
|
27
26
|
const result = await promiseSpawn(
|
|
28
27
|
cmd,
|
|
29
28
|
args ?? [],
|
|
30
|
-
{ ...opts, stdio, stdioString: true, shell: true },
|
|
31
|
-
extras
|
|
29
|
+
{ ...opts, stdio: 'pipe', stdioString: true, shell: true },
|
|
30
|
+
extras,
|
|
32
31
|
);
|
|
33
32
|
|
|
33
|
+
if (isDebug()) {
|
|
34
|
+
console.log(`codifySpawn result for: ${cmd}`);
|
|
35
|
+
console.log(JSON.stringify(result, null, 2))
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
const status = (result.code === 0 && !result.stderr)
|
|
35
39
|
? SpawnStatus.SUCCESS
|
|
36
40
|
: SpawnStatus.ERROR;
|
|
@@ -48,5 +52,5 @@ export async function codifySpawn(
|
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export function isDebug(): boolean {
|
|
51
|
-
return process.env.DEBUG != null && process.env.DEBUG.includes('codify');
|
|
55
|
+
return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
|
|
52
56
|
}
|