@storm-software/config-tools 1.190.153 → 1.190.154

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.
@@ -41,10 +41,10 @@ const run = (config, command, cwd = config.workspaceRoot ?? process.cwd(), stdio
41
41
  * @param command - The command to run
42
42
  * @param cwd - The current working directory
43
43
  * @param env - The environment variables
44
- * @returns A promise with the result of the command
44
+ * @returns The child process. It is thenable and settles when the process exits.
45
45
  */
46
46
  const runAsync = (config, command, cwd = config.workspaceRoot ?? process.cwd(), env = process.env) => {
47
- return (0, node_child_process.exec)(command, {
47
+ const child = (0, node_child_process.exec)(command, {
48
48
  cwd,
49
49
  env: {
50
50
  ...process.env,
@@ -57,6 +57,23 @@ const runAsync = (config, command, cwd = config.workspaceRoot ?? process.cwd(),
57
57
  killSignal: "SIGTERM",
58
58
  encoding: "utf8"
59
59
  });
60
+ child.stdout?.pipe(process.stdout);
61
+ child.stderr?.pipe(process.stderr);
62
+ const done = new Promise((resolve, reject) => {
63
+ child.once("error", reject);
64
+ child.once("close", (code) => {
65
+ if (code === 0) {
66
+ resolve();
67
+ return;
68
+ }
69
+ reject(/* @__PURE__ */ new Error(`Command failed with exit code ${code ?? "null"}: ${command}`));
70
+ });
71
+ });
72
+ return Object.assign(child, {
73
+ then: done.then.bind(done),
74
+ catch: done.catch.bind(done),
75
+ finally: done.finally.bind(done)
76
+ });
60
77
  };
61
78
  exports.LARGE_BUFFER = LARGE_BUFFER;
62
79
  exports.run = run;
@@ -1,4 +1,5 @@
1
1
  import { StormWorkspaceConfig } from "@storm-software/config";
2
+ import { ChildProcess } from "node:child_process";
2
3
  declare const LARGE_BUFFER: number;
3
4
  type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
4
5
  type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
@@ -26,7 +27,7 @@ declare const run: (config: Partial<StormWorkspaceConfig>, command: string, cwd?
26
27
  * @param command - The command to run
27
28
  * @param cwd - The current working directory
28
29
  * @param env - The environment variables
29
- * @returns A promise with the result of the command
30
+ * @returns The child process. It is thenable and settles when the process exits.
30
31
  */
31
- declare const runAsync: (config: Partial<StormWorkspaceConfig>, command: string, cwd?: string, env?: NodeJS.ProcessEnv) => import("node:child_process").ChildProcess;
32
+ declare const runAsync: (config: Partial<StormWorkspaceConfig>, command: string, cwd?: string, env?: NodeJS.ProcessEnv) => ChildProcess & PromiseLike<void>;
32
33
  export { IOType, LARGE_BUFFER, StdioOptions, run, runAsync };
@@ -1,6 +1,7 @@
1
1
  import __tsdown_shims_path from 'node:path';
2
2
  import __tsdown_shims_url from 'node:url';
3
3
  import { StormWorkspaceConfig } from "@storm-software/config";
4
+ import { ChildProcess } from "node:child_process";
4
5
  declare const LARGE_BUFFER: number;
5
6
  type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
6
7
  type StdioOptions = IOType | Array<IOType | "ipc" | number | null | undefined>;
@@ -28,7 +29,7 @@ declare const run: (config: Partial<StormWorkspaceConfig>, command: string, cwd?
28
29
  * @param command - The command to run
29
30
  * @param cwd - The current working directory
30
31
  * @param env - The environment variables
31
- * @returns A promise with the result of the command
32
+ * @returns The child process. It is thenable and settles when the process exits.
32
33
  */
33
- declare const runAsync: (config: Partial<StormWorkspaceConfig>, command: string, cwd?: string, env?: NodeJS.ProcessEnv) => import("node:child_process").ChildProcess;
34
+ declare const runAsync: (config: Partial<StormWorkspaceConfig>, command: string, cwd?: string, env?: NodeJS.ProcessEnv) => ChildProcess & PromiseLike<void>;
34
35
  export { IOType, LARGE_BUFFER, StdioOptions, run, runAsync };
@@ -43,10 +43,10 @@ const run = (config, command, cwd = config.workspaceRoot ?? process.cwd(), stdio
43
43
  * @param command - The command to run
44
44
  * @param cwd - The current working directory
45
45
  * @param env - The environment variables
46
- * @returns A promise with the result of the command
46
+ * @returns The child process. It is thenable and settles when the process exits.
47
47
  */
48
48
  const runAsync = (config, command, cwd = config.workspaceRoot ?? process.cwd(), env = process.env) => {
49
- return exec(command, {
49
+ const child = exec(command, {
50
50
  cwd,
51
51
  env: {
52
52
  ...process.env,
@@ -59,5 +59,22 @@ const runAsync = (config, command, cwd = config.workspaceRoot ?? process.cwd(),
59
59
  killSignal: "SIGTERM",
60
60
  encoding: "utf8"
61
61
  });
62
+ child.stdout?.pipe(process.stdout);
63
+ child.stderr?.pipe(process.stderr);
64
+ const done = new Promise((resolve, reject) => {
65
+ child.once("error", reject);
66
+ child.once("close", (code) => {
67
+ if (code === 0) {
68
+ resolve();
69
+ return;
70
+ }
71
+ reject(/* @__PURE__ */ new Error(`Command failed with exit code ${code ?? "null"}: ${command}`));
72
+ });
73
+ });
74
+ return Object.assign(child, {
75
+ then: done.then.bind(done),
76
+ catch: done.catch.bind(done),
77
+ finally: done.finally.bind(done)
78
+ });
62
79
  };
63
80
  export { LARGE_BUFFER, run, runAsync };
@@ -0,0 +1,12 @@
1
+ const require_utilities_run = require("./run.cjs");
2
+ // src/utilities/run.spec.ts
3
+ describe("runAsync", () => {
4
+ it("settles after the command exits", async () => {
5
+ const started = Date.now();
6
+ await require_utilities_run.runAsync({}, "node -e \"setTimeout(() => {}, 300)\"");
7
+ expect(Date.now() - started).toBeGreaterThanOrEqual(250);
8
+ });
9
+ it("rejects when the command exits non-zero", async () => {
10
+ await expect(require_utilities_run.runAsync({}, "node -e \"process.exit(2)\"")).rejects.toThrow(/exit code 2/);
11
+ });
12
+ });
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,2 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
@@ -0,0 +1,16 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { runAsync } from "./run.mjs";
5
+ // src/utilities/run.spec.ts
6
+ describe("runAsync", () => {
7
+ it("settles after the command exits", async () => {
8
+ const started = Date.now();
9
+ await runAsync({}, "node -e \"setTimeout(() => {}, 300)\"");
10
+ expect(Date.now() - started).toBeGreaterThanOrEqual(250);
11
+ });
12
+ it("rejects when the command exits non-zero", async () => {
13
+ await expect(runAsync({}, "node -e \"process.exit(2)\"")).rejects.toThrow(/exit code 2/);
14
+ });
15
+ });
16
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storm-software/config-tools",
3
- "version": "1.190.153",
3
+ "version": "1.190.154",
4
4
  "private": false,
5
5
  "description": "A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.",
6
6
  "keywords": [
@@ -147,6 +147,10 @@
147
147
  "import": "./dist/utilities/run.mjs",
148
148
  "require": "./dist/utilities/run.cjs"
149
149
  },
150
+ "./utilities/run.spec": {
151
+ "import": "./dist/utilities/run.spec.mjs",
152
+ "require": "./dist/utilities/run.spec.cjs"
153
+ },
150
154
  "./utilities/toml": {
151
155
  "import": "./dist/utilities/toml.mjs",
152
156
  "require": "./dist/utilities/toml.cjs"
@@ -164,7 +168,7 @@
164
168
  "files": ["dist"],
165
169
  "dependencies": {
166
170
  "@ltd/j-toml": "1.38.0",
167
- "@storm-software/config": "1.138.89",
171
+ "@storm-software/config": "1.138.90",
168
172
  "c12": "^2.0.4",
169
173
  "chalk": "^4.1.2",
170
174
  "commander": "^12.1.0",
@@ -182,5 +186,5 @@
182
186
  "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" },
183
187
  "peerDependenciesMeta": { "zod": { "optional": false } },
184
188
  "publishConfig": { "access": "public" },
185
- "gitHead": "7a502e974b390096b201737b87f85e793499bad2"
189
+ "gitHead": "669ee54da1367f7049b6e5b5f6e27ab208940a47"
186
190
  }