silgi 0.43.12 → 0.43.13

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.
@@ -5,28 +5,9 @@ import consola from "consola";
5
5
  import { useSilgiCLI } from "silgi";
6
6
  import { version } from "silgi/meta";
7
7
  import { runCommand } from "citty";
8
- import { spawn } from "node:child_process";
9
- import { platform } from "node:os";
10
- import { promisify } from "node:util";
11
- import treeKill from "tree-kill";
8
+ import { execa } from "execa";
12
9
 
13
10
  //#region src/cli/commands/run.ts
14
- const treeKillAsync = promisify(treeKill);
15
- function waitForProcess(proc) {
16
- return new Promise((resolve, reject) => {
17
- proc.on("exit", (code) => resolve(code ?? 0));
18
- proc.on("error", (err) => reject(err));
19
- });
20
- }
21
- async function killProcessTree(pid, signal = "SIGTERM") {
22
- try {
23
- await treeKillAsync(pid, signal);
24
- return true;
25
- } catch (error) {
26
- consola.warn(`Failed to kill process tree for PID ${pid}:`, error);
27
- return false;
28
- }
29
- }
30
11
  function setupSignalHandlers(onSignal) {
31
12
  const signals = [
32
13
  "SIGINT",
@@ -59,8 +40,8 @@ const command = {
59
40
  ] });
60
41
  const silgi = useSilgiCLI();
61
42
  const startCommand = args.command || rawArgs[0];
62
- let childPid = null;
63
43
  let hasExited = false;
44
+ let childProcess = null;
64
45
  const cleanupAndExit = async (code = 0) => {
65
46
  if (hasExited) return;
66
47
  hasExited = true;
@@ -71,24 +52,27 @@ const command = {
71
52
  const removeSignalHandlers = setupSignalHandlers(async (signal) => {
72
53
  consola.info(`Received ${signal}, terminating process...`);
73
54
  if (watcher?.close) await watcher.close().catch(() => {});
74
- if (childPid) await killProcessTree(childPid, signal);
55
+ if (childProcess) childProcess.kill(signal);
75
56
  await cleanupAndExit(0);
76
57
  });
77
58
  consola.info(`Starting command: nr ${startCommand}`);
78
- const isWindows = platform() === "win32";
79
- const proc = spawn("nr", [startCommand], {
59
+ childProcess = execa("nr", [startCommand], {
80
60
  stdio: "inherit",
81
61
  shell: true,
82
- cwd: process.cwd(),
83
- ...!isWindows && { detached: true }
62
+ cwd: process.cwd()
63
+ });
64
+ childProcess.on("exit", (code) => {
65
+ if (code !== 0) consola.error(`Process exited with code ${code}`);
66
+ else consola.success("Process exited successfully.");
67
+ removeSignalHandlers();
68
+ cleanupAndExit(code ?? 0);
69
+ });
70
+ childProcess.on("error", (err) => {
71
+ consola.error("Child process error:", err);
72
+ removeSignalHandlers();
73
+ cleanupAndExit(1);
84
74
  });
85
- childPid = proc.pid ?? null;
86
- if (!childPid) throw new Error("Failed to start child process: no PID assigned");
87
- const exitCode = await waitForProcess(proc);
88
- if (exitCode !== 0) consola.error(`Process exited with code ${exitCode}`);
89
- else consola.success("Process exited successfully.");
90
- removeSignalHandlers();
91
- await cleanupAndExit(exitCode);
75
+ await childProcess;
92
76
  } catch (error) {
93
77
  consola.error(`Failed to start the development server: ${error instanceof Error ? error.message : error}`);
94
78
  if (silgi.options.debug) consola.withTag("silgi").error("Error while running the command", error);
package/dist/package.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var name = "silgi";
3
3
  var type = "module";
4
- var version = "0.43.12";
4
+ var version = "0.43.13";
5
5
  var private$1 = false;
6
6
  var packageManager = "pnpm@10.12.2";
7
7
  var sideEffects = false;
@@ -90,6 +90,7 @@ var dependencies = {
90
90
  "dot-prop": "catalog:",
91
91
  "dotenv": "catalog:",
92
92
  "escape-string-regexp": "catalog:",
93
+ "execa": "^9.6.0",
93
94
  "exsolve": "^1.0.7",
94
95
  "graphql": "^16.11.0",
95
96
  "hookable": "catalog:",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.43.12",
4
+ "version": "0.43.13",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {
@@ -99,6 +99,7 @@
99
99
  "dot-prop": "^9.0.0",
100
100
  "dotenv": "^16.5.0",
101
101
  "escape-string-regexp": "^5.0.0",
102
+ "execa": "^9.6.0",
102
103
  "exsolve": "^1.0.7",
103
104
  "graphql": "^16.11.0",
104
105
  "hookable": "^5.5.3",