codify-plugin-lib 1.0.16 → 1.0.17

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,17 @@ 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
15
  const stdio = isDebug() ? 'inherit' : 'pipe';
16
16
  const result = await (0, promise_spawn_1.default)(cmd, args ?? [], { ...opts, stdio, stdioString: true, shell: true }, extras);
17
+ if (isDebug()) {
18
+ console.log(`codifySpawn result for: ${cmd}`);
19
+ console.log(JSON.stringify(result, null, 2));
20
+ }
17
21
  const status = (result.code === 0 && !result.stderr)
18
22
  ? SpawnStatus.SUCCESS
19
23
  : 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.17",
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 {
@@ -31,6 +31,11 @@ export async function codifySpawn(
31
31
  extras
32
32
  );
33
33
 
34
+ if (isDebug()) {
35
+ console.log(`codifySpawn result for: ${cmd}`);
36
+ console.log(JSON.stringify(result, null, 2))
37
+ }
38
+
34
39
  const status = (result.code === 0 && !result.stderr)
35
40
  ? SpawnStatus.SUCCESS
36
41
  : SpawnStatus.ERROR;
@@ -48,5 +53,5 @@ export async function codifySpawn(
48
53
  }
49
54
 
50
55
  export function isDebug(): boolean {
51
- return process.env.DEBUG != null && process.env.DEBUG.includes('codify');
56
+ return process.env.DEBUG != null && process.env.DEBUG.includes('codify'); // TODO: replace with debug library
52
57
  }