@cydm/magic-shell-agent-node 0.1.12 → 0.1.14
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.
|
@@ -6,6 +6,14 @@ import { fileURLToPath } from "url";
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
|
+
const DEFAULT_WINDOWS_SHELL = process.env.ComSpec || "C:\\Windows\\System32\\cmd.exe";
|
|
10
|
+
function quoteWindowsArg(value) {
|
|
11
|
+
if (!value)
|
|
12
|
+
return "\"\"";
|
|
13
|
+
if (!/[\s"]/u.test(value))
|
|
14
|
+
return value;
|
|
15
|
+
return `"${value.replace(/"/g, '\\"')}"`;
|
|
16
|
+
}
|
|
9
17
|
function resolvePackageBinScript(packageName, binName) {
|
|
10
18
|
try {
|
|
11
19
|
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
@@ -38,6 +46,13 @@ function resolveWindowsCommand(command, args) {
|
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
}
|
|
49
|
+
const lowerCommand = command.toLowerCase();
|
|
50
|
+
if (lowerCommand.endsWith(".cmd") || lowerCommand.endsWith(".bat")) {
|
|
51
|
+
return {
|
|
52
|
+
command: DEFAULT_WINDOWS_SHELL,
|
|
53
|
+
args: ["/d", "/s", "/c", [quoteWindowsArg(command), ...args.map(quoteWindowsArg)].join(" ")],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
41
56
|
if (command.includes("\\") || command.includes("/") || /^[a-zA-Z]:/.test(command)) {
|
|
42
57
|
return { command, args };
|
|
43
58
|
}
|
|
@@ -54,10 +69,24 @@ function resolveWindowsCommand(command, args) {
|
|
|
54
69
|
for (const ext of pathext) {
|
|
55
70
|
const candidate = `${entry}\\${command}${ext.toLowerCase()}`;
|
|
56
71
|
if (existsSync(candidate)) {
|
|
72
|
+
const lowerExt = ext.toLowerCase();
|
|
73
|
+
if (lowerExt === ".cmd" || lowerExt === ".bat") {
|
|
74
|
+
return {
|
|
75
|
+
command: DEFAULT_WINDOWS_SHELL,
|
|
76
|
+
args: ["/d", "/s", "/c", [quoteWindowsArg(candidate), ...args.map(quoteWindowsArg)].join(" ")],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
57
79
|
return { command: candidate, args };
|
|
58
80
|
}
|
|
59
81
|
const candidateUpper = `${entry}\\${command}${ext.toUpperCase()}`;
|
|
60
82
|
if (existsSync(candidateUpper)) {
|
|
83
|
+
const upperExt = ext.toUpperCase();
|
|
84
|
+
if (upperExt === ".CMD" || upperExt === ".BAT") {
|
|
85
|
+
return {
|
|
86
|
+
command: DEFAULT_WINDOWS_SHELL,
|
|
87
|
+
args: ["/d", "/s", "/c", [quoteWindowsArg(candidateUpper), ...args.map(quoteWindowsArg)].join(" ")],
|
|
88
|
+
};
|
|
89
|
+
}
|
|
61
90
|
return { command: candidateUpper, args };
|
|
62
91
|
}
|
|
63
92
|
}
|
package/dist/plugin-loader.js
CHANGED
|
@@ -8,7 +8,7 @@ export function loadPlugin(path) {
|
|
|
8
8
|
if (!existsSync(path)) {
|
|
9
9
|
throw new Error(`Plugin file not found: ${path}`);
|
|
10
10
|
}
|
|
11
|
-
const content = readFileSync(path, "utf-8");
|
|
11
|
+
const content = readFileSync(path, "utf-8").replace(/^\uFEFF/, "");
|
|
12
12
|
const config = JSON.parse(content);
|
|
13
13
|
const configDir = dirname(path);
|
|
14
14
|
const repoRoot = dirname(configDir);
|