@rienn/guanyuan-cli 0.7.1 → 0.8.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/bin/guanyuan.js
CHANGED
|
@@ -10,9 +10,15 @@ const os = require("os");
|
|
|
10
10
|
const PKG = "@rienn/guanyuan-cli";
|
|
11
11
|
|
|
12
12
|
if (process.argv[2] === "update" || process.argv[2] === "upgrade") {
|
|
13
|
-
const
|
|
13
|
+
const isWin = os.platform() === "win32";
|
|
14
14
|
console.error(`更新 ${PKG} 到最新版...`);
|
|
15
|
-
|
|
15
|
+
// Windows 必须 shell:true。Node 修 CVE-2024-27980 后收紧了对 .cmd/.bat 的直接 spawn,
|
|
16
|
+
// 再直接 spawnSync("npm.cmd") 会抛 EINVAL —— 也就是说 update 命令本身在 Windows 上是坏的。
|
|
17
|
+
// 参数全是写死的常量,没有用户输入拼进命令行,不存在注入面。
|
|
18
|
+
const res = spawnSync(isWin ? "npm.cmd" : "npm", ["install", "-g", `${PKG}@latest`], {
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
shell: isWin,
|
|
21
|
+
});
|
|
16
22
|
if (res.error) {
|
|
17
23
|
console.error(`更新失败: ${res.error.message}`);
|
|
18
24
|
console.error(`请手动执行: npm install -g ${PKG}@latest(检查 npm registry / 代理 / 权限)`);
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|