@spikonado/sprocket 0.4.0 → 0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152
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/lib/launcher.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
2
|
import { accessSync, chmodSync, constants, readFileSync } from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -63,18 +63,49 @@ export function ensureExecutable(binary) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function run(binary, args, options = {}) {
|
|
67
|
-
const
|
|
66
|
+
export async function run(binary, args, options = {}) {
|
|
67
|
+
const child = (options.spawn ?? spawn)(binary, args, {
|
|
68
68
|
stdio: 'inherit',
|
|
69
69
|
env: options.env ?? process.env
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
let interrupted;
|
|
73
|
+
|
|
74
|
+
const handlers = new Map(
|
|
75
|
+
['SIGINT', 'SIGTERM'].map((signal) => [
|
|
76
|
+
signal,
|
|
77
|
+
() => {
|
|
78
|
+
interrupted ??= signal;
|
|
79
|
+
|
|
80
|
+
// Windows already sends Ctrl+C to both processes; child.kill would force termination.
|
|
81
|
+
if (process.platform !== 'win32' || signal !== 'SIGINT') {
|
|
82
|
+
child.kill(signal);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
])
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
for (const [signal, handler] of handlers) {
|
|
89
|
+
process.on(signal, handler);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let result;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
result = await new Promise((resolve, reject) => {
|
|
96
|
+
child.once('error', reject);
|
|
97
|
+
child.once('close', (status, signal) => resolve({ status, signal }));
|
|
98
|
+
});
|
|
99
|
+
} finally {
|
|
100
|
+
for (const [signal, handler] of handlers) {
|
|
101
|
+
process.off(signal, handler);
|
|
102
|
+
}
|
|
74
103
|
}
|
|
75
104
|
|
|
76
|
-
|
|
77
|
-
|
|
105
|
+
const signal = result.signal ?? interrupted;
|
|
106
|
+
|
|
107
|
+
if (signal) {
|
|
108
|
+
process.kill(process.pid, signal);
|
|
78
109
|
|
|
79
110
|
return undefined;
|
|
80
111
|
}
|
|
@@ -112,7 +143,7 @@ export async function launch(args, options = {}) {
|
|
|
112
143
|
const staticDir = path.resolve(libDir, '../web');
|
|
113
144
|
const binary = (options.resolveBinary ?? resolveNativeBinary)();
|
|
114
145
|
(options.ensureExecutable ?? ensureExecutable)(binary);
|
|
115
|
-
process.exitCode = run(binary, args, {
|
|
146
|
+
process.exitCode = await run(binary, args, {
|
|
116
147
|
env: nativeChildEnvironment(
|
|
117
148
|
env,
|
|
118
149
|
staticDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spikonado/sprocket",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152",
|
|
4
4
|
"description": "Agentic platform for streamlining hardware and software development",
|
|
5
5
|
"license": "FSL-1.1-ALv2",
|
|
6
6
|
"type": "module",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@spikonado/sprocket-linux-x64-gnu": "0.4.
|
|
34
|
-
"@spikonado/sprocket-linux-arm64-gnu": "0.4.
|
|
35
|
-
"@spikonado/sprocket-darwin-x64": "0.4.
|
|
36
|
-
"@spikonado/sprocket-darwin-arm64": "0.4.
|
|
37
|
-
"@spikonado/sprocket-win32-x64-msvc": "0.4.
|
|
33
|
+
"@spikonado/sprocket-linux-x64-gnu": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152",
|
|
34
|
+
"@spikonado/sprocket-linux-arm64-gnu": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152",
|
|
35
|
+
"@spikonado/sprocket-darwin-x64": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152",
|
|
36
|
+
"@spikonado/sprocket-darwin-arm64": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152",
|
|
37
|
+
"@spikonado/sprocket-win32-x64-msvc": "0.4.1-dev.3166dbe545645fb3149df2ca4ec1b38f86150152"
|
|
38
38
|
}
|
|
39
39
|
}
|