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.
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { SpawnOptions } from 'child_process';
3
3
  export declare enum SpawnStatus {
4
- SUCCESS = 0,
5
- ERROR = 1
4
+ SUCCESS = "success",
5
+ ERROR = "error"
6
6
  }
7
7
  export interface SpawnResult {
8
8
  status: SpawnStatus;
@@ -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[SpawnStatus["SUCCESS"] = 0] = "SUCCESS";
11
- SpawnStatus[SpawnStatus["ERROR"] = 1] = "ERROR";
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 stdio = isDebug() ? 'inherit' : 'pipe';
16
- const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio, stdioString: true, shell: true }, extras);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -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
  }