poseref 0.1.0 → 0.1.1
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/dist-server/cli.js +19 -4
- package/package.json +1 -1
package/dist-server/cli.js
CHANGED
|
@@ -2324,14 +2324,29 @@ function registrationEnv(port = resolvePort()) {
|
|
|
2324
2324
|
}
|
|
2325
2325
|
/** Every argument PoseRef passes to another CLI is a fixed word or a version, never user text. */
|
|
2326
2326
|
var SAFE_ARG = /^[\w@.:/=-]+$/;
|
|
2327
|
-
|
|
2327
|
+
/**
|
|
2328
|
+
* Joins a command for the Windows shell. claude and codex are .cmd shims there,
|
|
2329
|
+
* which Node can only start through a shell; building the line ourselves (rather
|
|
2330
|
+
* than passing an args array with `shell: true`, which Node deprecates because it
|
|
2331
|
+
* concatenates without escaping) keeps the check on every piece explicit. Pieces
|
|
2332
|
+
* are limited to SAFE_ARG, which has no spaces or shell metacharacters, so they
|
|
2333
|
+
* need no quoting.
|
|
2334
|
+
*/
|
|
2335
|
+
function shellCommandLine(command, args) {
|
|
2328
2336
|
for (const arg of [command, ...args]) if (!SAFE_ARG.test(arg)) throw new Error(`Refusing to run a command with an unexpected argument: ${arg}`);
|
|
2329
|
-
|
|
2337
|
+
return [command, ...args].join(" ");
|
|
2338
|
+
}
|
|
2339
|
+
function run(command, args) {
|
|
2340
|
+
const line = shellCommandLine(command, args);
|
|
2341
|
+
const options = {
|
|
2330
2342
|
encoding: "utf8",
|
|
2331
|
-
shell: process.platform === "win32",
|
|
2332
2343
|
windowsHide: true,
|
|
2333
2344
|
timeout: 6e4
|
|
2334
|
-
}
|
|
2345
|
+
};
|
|
2346
|
+
const result = process.platform === "win32" ? spawnSync(line, {
|
|
2347
|
+
...options,
|
|
2348
|
+
shell: true
|
|
2349
|
+
}) : spawnSync(command, args, options);
|
|
2335
2350
|
return {
|
|
2336
2351
|
ok: result.status === 0,
|
|
2337
2352
|
output: `${result.stdout ?? ""}${result.stderr ?? ""}`.trim()
|