@igorlau/dotagents 1.0.17 → 1.0.18
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/build-info.json +1 -1
- package/dist/commands.js +14 -1
- package/package.json +1 -1
package/dist/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commit":"
|
|
1
|
+
{"commit":"85a839f"}
|
package/dist/commands.js
CHANGED
|
@@ -296,6 +296,19 @@ export function setCheckHook(cwd, enabled, dryRun) {
|
|
|
296
296
|
export function selfUpdate(args) {
|
|
297
297
|
const source = readSource();
|
|
298
298
|
log(`Running the latest dotagents from ${source}:`);
|
|
299
|
-
const
|
|
299
|
+
const npx = npxCommand(["--yes", "--prefer-online", source, "update", ...args]);
|
|
300
|
+
const result = spawnSync(npx.command, npx.args, { shell: npx.shell, stdio: "inherit" });
|
|
300
301
|
return result.status === 0;
|
|
301
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Builds the command that starts `npx`. On Windows, `npx` is `npx.cmd`, which Node starts only through a shell,
|
|
305
|
+
* so the arguments go into one quoted command line. `cmd.exe` still reads `"` and `%` inside quotes, so those throw.
|
|
306
|
+
*/
|
|
307
|
+
export function npxCommand(args, platform = process.platform) {
|
|
308
|
+
if (platform !== "win32")
|
|
309
|
+
return { args, command: "npx", shell: false };
|
|
310
|
+
const unsafe = args.find((arg) => /["%]/.test(arg));
|
|
311
|
+
if (unsafe !== undefined)
|
|
312
|
+
throw new Error(`Cannot pass ${unsafe} to npx on Windows. Remove the " and % characters.`);
|
|
313
|
+
return { args: [], command: ["npx", ...args.map((arg) => `"${arg}"`)].join(" "), shell: true };
|
|
314
|
+
}
|