@shell-shock/core 0.17.3 → 0.17.4
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/components/exec-builtin.cjs +90 -97
- package/dist/components/exec-builtin.mjs +90 -97
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +1 -1
- package/dist/components/state-builtin.mjs +1 -1
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +1 -10
- package/dist/components/utils-builtin.mjs +1 -10
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +1 -1
- package/dist/plugin.cjs +3 -0
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +2 -0
- package/dist/plugin.mjs.map +1 -1
- package/dist/types/config.cjs +3 -2
- package/dist/types/config.d.cts +3 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +3 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +3 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/env.cjs +31 -1
- package/dist/types/env.mjs +31 -1
- package/package.json +11 -11
|
@@ -41,14 +41,7 @@ function ExecBuiltin(props) {
|
|
|
41
41
|
});
|
|
42
42
|
},
|
|
43
43
|
get builtinImports() {
|
|
44
|
-
return (0, defu.default)(rest.builtinImports ?? {}, { env: [
|
|
45
|
-
"isWindows",
|
|
46
|
-
"env",
|
|
47
|
-
{
|
|
48
|
-
name: "Env",
|
|
49
|
-
type: true
|
|
50
|
-
}
|
|
51
|
-
] });
|
|
44
|
+
return (0, defu.default)(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
|
|
52
45
|
},
|
|
53
46
|
get children() {
|
|
54
47
|
return [
|
|
@@ -60,32 +53,32 @@ function ExecBuiltin(props) {
|
|
|
60
53
|
}],
|
|
61
54
|
returnType: "NodeJS.ProcessEnv",
|
|
62
55
|
children: _alloy_js_core.code`const argv = params.argv;
|
|
63
|
-
const shouldSuppressNpmFund = (() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
const shouldSuppressNpmFund = (() => {
|
|
57
|
+
const cmd = basename(argv[0] ?? "");
|
|
58
|
+
if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (cmd === "node" || cmd === "node.exe") {
|
|
62
|
+
const script = argv[1] ?? "";
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
})();
|
|
64
|
+
return script.includes("npm-cli.js");
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
})();
|
|
75
68
|
|
|
76
|
-
const result = Object.fromEntries(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
);
|
|
84
|
-
if (shouldSuppressNpmFund) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return result; `
|
|
69
|
+
const result = Object.fromEntries(
|
|
70
|
+
Object.entries({
|
|
71
|
+
...env,
|
|
72
|
+
...(params.env ?? {})
|
|
73
|
+
})
|
|
74
|
+
.filter(([, value]) => value !== undefined)
|
|
75
|
+
.map(([key, value]) => [key, String(value)])
|
|
76
|
+
);
|
|
77
|
+
if (shouldSuppressNpmFund) {
|
|
78
|
+
result.NPM_CONFIG_FUND ??= "false";
|
|
79
|
+
result.npm_config_fund ??= "false";
|
|
80
|
+
}
|
|
81
|
+
return result; `
|
|
89
82
|
}),
|
|
90
83
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
91
84
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -96,11 +89,11 @@ return result; `
|
|
|
96
89
|
}],
|
|
97
90
|
returnType: "boolean",
|
|
98
91
|
children: _alloy_js_core.code`if (!isWindows) {
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
const ext = extname(resolvedCommand).toLowerCase();
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const ext = extname(resolvedCommand).toLowerCase();
|
|
102
95
|
|
|
103
|
-
return ext === ".cmd" || ext === ".bat"
|
|
96
|
+
return ext === ".cmd" || ext === ".bat"; `
|
|
104
97
|
}),
|
|
105
98
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
106
99
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -111,15 +104,15 @@ return ext === ".cmd" || ext === ".bat";`
|
|
|
111
104
|
}],
|
|
112
105
|
returnType: "string",
|
|
113
106
|
children: _alloy_js_core.code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
return \`"\${arg.replace(/"/g, '""')}"
|
|
107
|
+
throw new Error(
|
|
108
|
+
\`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
|
|
109
|
+
"Pass an explicit shell-wrapper argv at the call site instead."
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
113
|
+
return arg;
|
|
114
|
+
}
|
|
115
|
+
return \`"\${arg.replace(/"/g, '""')}"\`; `
|
|
123
116
|
}),
|
|
124
117
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
125
118
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -133,8 +126,8 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
133
126
|
}],
|
|
134
127
|
returnType: "string",
|
|
135
128
|
children: _alloy_js_core.code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
|
|
136
|
-
|
|
137
|
-
)
|
|
129
|
+
" "
|
|
130
|
+
); `
|
|
138
131
|
}),
|
|
139
132
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
140
133
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -146,26 +139,26 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
146
139
|
}],
|
|
147
140
|
returnType: "string[] | null",
|
|
148
141
|
children: _alloy_js_core.code`if (!isWindows || argv.length === 0) {
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
const base = basename(argv[0] ?? "")
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const cliName =
|
|
155
|
-
|
|
156
|
-
if (!cliName) {
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
const nodeDir = dirname(process.execPath);
|
|
160
|
-
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
161
|
-
if (!existsSync(cliPath)) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const base = basename(argv[0] ?? "")
|
|
145
|
+
.toLowerCase()
|
|
146
|
+
.replace(/\.(?:cmd|exe|bat)$/, "");
|
|
147
|
+
const cliName =
|
|
148
|
+
base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
|
|
149
|
+
if (!cliName) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const nodeDir = dirname(process.execPath);
|
|
153
|
+
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
154
|
+
if (!existsSync(cliPath)) {
|
|
155
|
+
const command = argv[0] ?? "";
|
|
156
|
+
const ext = extname(command).toLowerCase();
|
|
157
|
+
const shimmedCommand = ext ? command : \`\${command}.cmd\`;
|
|
165
158
|
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
return [process.execPath, cliPath, ...argv.slice(1)]
|
|
159
|
+
return [shimmedCommand, ...argv.slice(1)];
|
|
160
|
+
}
|
|
161
|
+
return [process.execPath, cliPath, ...argv.slice(1)]; `
|
|
169
162
|
}),
|
|
170
163
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
171
164
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -177,16 +170,16 @@ return [process.execPath, cliPath, ...argv.slice(1)];`
|
|
|
177
170
|
}],
|
|
178
171
|
returnType: "string",
|
|
179
172
|
children: _alloy_js_core.code`if (!isWindows) {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
const base = basename(command).toLowerCase();
|
|
183
|
-
if (extname(base)) {
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
if (["pnpm", "yarn"].includes(base)) {
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
return command
|
|
173
|
+
return command;
|
|
174
|
+
}
|
|
175
|
+
const base = basename(command).toLowerCase();
|
|
176
|
+
if (extname(base)) {
|
|
177
|
+
return command;
|
|
178
|
+
}
|
|
179
|
+
if (["pnpm", "yarn"].includes(base)) {
|
|
180
|
+
return \`\${command}.cmd\`;
|
|
181
|
+
}
|
|
182
|
+
return command; `
|
|
190
183
|
}),
|
|
191
184
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
192
185
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -197,12 +190,12 @@ return command;`
|
|
|
197
190
|
}],
|
|
198
191
|
returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
|
|
199
192
|
children: _alloy_js_core.code`const stdin = params.hasInput
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
193
|
+
? "pipe"
|
|
194
|
+
: params.preferInherit
|
|
195
|
+
? "inherit"
|
|
196
|
+
: "pipe";
|
|
204
197
|
|
|
205
|
-
return [stdin, "pipe", "pipe"]
|
|
198
|
+
return [stdin, "pipe", "pipe"]; `
|
|
206
199
|
}),
|
|
207
200
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
208
201
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -213,16 +206,16 @@ return [stdin, "pipe", "pipe"];`
|
|
|
213
206
|
}],
|
|
214
207
|
returnType: "number | null",
|
|
215
208
|
children: _alloy_js_core.code`return (
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
)
|
|
209
|
+
params.explicitCode ??
|
|
210
|
+
params.childExitCode ??
|
|
211
|
+
(params.usesWindowsExitCodeShim &&
|
|
212
|
+
params.resolvedSignal == null &&
|
|
213
|
+
!params.timedOut &&
|
|
214
|
+
!params.noOutputTimedOut &&
|
|
215
|
+
!params.killIssuedByTimeout
|
|
216
|
+
? 0
|
|
217
|
+
: null)
|
|
218
|
+
); `
|
|
226
219
|
}),
|
|
227
220
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
228
221
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
@@ -233,12 +226,12 @@ return [stdin, "pipe", "pipe"];`
|
|
|
233
226
|
}],
|
|
234
227
|
returnType: "boolean",
|
|
235
228
|
children: _alloy_js_core.code`// SECURITY: never enable \`shell\` for argv-based execution.
|
|
236
|
-
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
237
|
-
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
238
|
-
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
239
|
-
// and validate/escape at the call site.
|
|
240
|
-
void params;
|
|
241
|
-
return false
|
|
229
|
+
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
230
|
+
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
231
|
+
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
232
|
+
// and validate/escape at the call site.
|
|
233
|
+
void params;
|
|
234
|
+
return false; `
|
|
242
235
|
}),
|
|
243
236
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
244
237
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "The result of a spawn operation." }),
|
|
@@ -38,14 +38,7 @@ function ExecBuiltin(props) {
|
|
|
38
38
|
});
|
|
39
39
|
},
|
|
40
40
|
get builtinImports() {
|
|
41
|
-
return defu$1(rest.builtinImports ?? {}, { env: [
|
|
42
|
-
"isWindows",
|
|
43
|
-
"env",
|
|
44
|
-
{
|
|
45
|
-
name: "Env",
|
|
46
|
-
type: true
|
|
47
|
-
}
|
|
48
|
-
] });
|
|
41
|
+
return defu$1(rest.builtinImports ?? {}, { env: ["isWindows", "env"] });
|
|
49
42
|
},
|
|
50
43
|
get children() {
|
|
51
44
|
return [
|
|
@@ -57,32 +50,32 @@ function ExecBuiltin(props) {
|
|
|
57
50
|
}],
|
|
58
51
|
returnType: "NodeJS.ProcessEnv",
|
|
59
52
|
children: code`const argv = params.argv;
|
|
60
|
-
const shouldSuppressNpmFund = (() => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
const shouldSuppressNpmFund = (() => {
|
|
54
|
+
const cmd = basename(argv[0] ?? "");
|
|
55
|
+
if (cmd === "npm" || cmd === "npm.cmd" || cmd === "npm.exe") {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
if (cmd === "node" || cmd === "node.exe") {
|
|
59
|
+
const script = argv[1] ?? "";
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
})();
|
|
61
|
+
return script.includes("npm-cli.js");
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
})();
|
|
72
65
|
|
|
73
|
-
const result = Object.fromEntries(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
);
|
|
81
|
-
if (shouldSuppressNpmFund) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
return result; `
|
|
66
|
+
const result = Object.fromEntries(
|
|
67
|
+
Object.entries({
|
|
68
|
+
...env,
|
|
69
|
+
...(params.env ?? {})
|
|
70
|
+
})
|
|
71
|
+
.filter(([, value]) => value !== undefined)
|
|
72
|
+
.map(([key, value]) => [key, String(value)])
|
|
73
|
+
);
|
|
74
|
+
if (shouldSuppressNpmFund) {
|
|
75
|
+
result.NPM_CONFIG_FUND ??= "false";
|
|
76
|
+
result.npm_config_fund ??= "false";
|
|
77
|
+
}
|
|
78
|
+
return result; `
|
|
86
79
|
}),
|
|
87
80
|
createComponent(Spacing, {}),
|
|
88
81
|
createComponent(FunctionDeclaration, {
|
|
@@ -93,11 +86,11 @@ return result; `
|
|
|
93
86
|
}],
|
|
94
87
|
returnType: "boolean",
|
|
95
88
|
children: code`if (!isWindows) {
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const ext = extname(resolvedCommand).toLowerCase();
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const ext = extname(resolvedCommand).toLowerCase();
|
|
99
92
|
|
|
100
|
-
return ext === ".cmd" || ext === ".bat"
|
|
93
|
+
return ext === ".cmd" || ext === ".bat"; `
|
|
101
94
|
}),
|
|
102
95
|
createComponent(Spacing, {}),
|
|
103
96
|
createComponent(FunctionDeclaration, {
|
|
@@ -108,15 +101,15 @@ return ext === ".cmd" || ext === ".bat";`
|
|
|
108
101
|
}],
|
|
109
102
|
returnType: "string",
|
|
110
103
|
children: code`if (/[&|<>^%\\\\r\\\\n]/.test(arg)) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
return \`"\${arg.replace(/"/g, '""')}"
|
|
104
|
+
throw new Error(
|
|
105
|
+
\`Unsafe Windows cmd.exe argument detected: \${JSON.stringify(arg)}. \` +
|
|
106
|
+
"Pass an explicit shell-wrapper argv at the call site instead."
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (!arg.includes(" ") && !arg.includes('"')) {
|
|
110
|
+
return arg;
|
|
111
|
+
}
|
|
112
|
+
return \`"\${arg.replace(/"/g, '""')}"\`; `
|
|
120
113
|
}),
|
|
121
114
|
createComponent(Spacing, {}),
|
|
122
115
|
createComponent(FunctionDeclaration, {
|
|
@@ -130,8 +123,8 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
130
123
|
}],
|
|
131
124
|
returnType: "string",
|
|
132
125
|
children: code`return [escapeForCmdExe(resolvedCommand), ...args.map(escapeForCmdExe)].join(
|
|
133
|
-
|
|
134
|
-
)
|
|
126
|
+
" "
|
|
127
|
+
); `
|
|
135
128
|
}),
|
|
136
129
|
createComponent(Spacing, {}),
|
|
137
130
|
createComponent(FunctionDeclaration, {
|
|
@@ -143,26 +136,26 @@ return \`"\${arg.replace(/"/g, '""')}"\`;`
|
|
|
143
136
|
}],
|
|
144
137
|
returnType: "string[] | null",
|
|
145
138
|
children: code`if (!isWindows || argv.length === 0) {
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
const base = basename(argv[0] ?? "")
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const cliName =
|
|
152
|
-
|
|
153
|
-
if (!cliName) {
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
const nodeDir = dirname(process.execPath);
|
|
157
|
-
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
158
|
-
if (!existsSync(cliPath)) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
const base = basename(argv[0] ?? "")
|
|
142
|
+
.toLowerCase()
|
|
143
|
+
.replace(/\.(?:cmd|exe|bat)$/, "");
|
|
144
|
+
const cliName =
|
|
145
|
+
base === "npx" ? "npx-cli.js" : base === "npm" ? "npm-cli.js" : null;
|
|
146
|
+
if (!cliName) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const nodeDir = dirname(process.execPath);
|
|
150
|
+
const cliPath = join(nodeDir, "node_modules", "npm", "bin", cliName);
|
|
151
|
+
if (!existsSync(cliPath)) {
|
|
152
|
+
const command = argv[0] ?? "";
|
|
153
|
+
const ext = extname(command).toLowerCase();
|
|
154
|
+
const shimmedCommand = ext ? command : \`\${command}.cmd\`;
|
|
162
155
|
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
return [process.execPath, cliPath, ...argv.slice(1)]
|
|
156
|
+
return [shimmedCommand, ...argv.slice(1)];
|
|
157
|
+
}
|
|
158
|
+
return [process.execPath, cliPath, ...argv.slice(1)]; `
|
|
166
159
|
}),
|
|
167
160
|
createComponent(Spacing, {}),
|
|
168
161
|
createComponent(FunctionDeclaration, {
|
|
@@ -174,16 +167,16 @@ return [process.execPath, cliPath, ...argv.slice(1)];`
|
|
|
174
167
|
}],
|
|
175
168
|
returnType: "string",
|
|
176
169
|
children: code`if (!isWindows) {
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
const base = basename(command).toLowerCase();
|
|
180
|
-
if (extname(base)) {
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
if (["pnpm", "yarn"].includes(base)) {
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
return command
|
|
170
|
+
return command;
|
|
171
|
+
}
|
|
172
|
+
const base = basename(command).toLowerCase();
|
|
173
|
+
if (extname(base)) {
|
|
174
|
+
return command;
|
|
175
|
+
}
|
|
176
|
+
if (["pnpm", "yarn"].includes(base)) {
|
|
177
|
+
return \`\${command}.cmd\`;
|
|
178
|
+
}
|
|
179
|
+
return command; `
|
|
187
180
|
}),
|
|
188
181
|
createComponent(Spacing, {}),
|
|
189
182
|
createComponent(FunctionDeclaration, {
|
|
@@ -194,12 +187,12 @@ return command;`
|
|
|
194
187
|
}],
|
|
195
188
|
returnType: "[\"pipe\" | \"inherit\" | \"ignore\", \"pipe\", \"pipe\"]",
|
|
196
189
|
children: code`const stdin = params.hasInput
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
? "pipe"
|
|
191
|
+
: params.preferInherit
|
|
192
|
+
? "inherit"
|
|
193
|
+
: "pipe";
|
|
201
194
|
|
|
202
|
-
return [stdin, "pipe", "pipe"]
|
|
195
|
+
return [stdin, "pipe", "pipe"]; `
|
|
203
196
|
}),
|
|
204
197
|
createComponent(Spacing, {}),
|
|
205
198
|
createComponent(FunctionDeclaration, {
|
|
@@ -210,16 +203,16 @@ return [stdin, "pipe", "pipe"];`
|
|
|
210
203
|
}],
|
|
211
204
|
returnType: "number | null",
|
|
212
205
|
children: code`return (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
)
|
|
206
|
+
params.explicitCode ??
|
|
207
|
+
params.childExitCode ??
|
|
208
|
+
(params.usesWindowsExitCodeShim &&
|
|
209
|
+
params.resolvedSignal == null &&
|
|
210
|
+
!params.timedOut &&
|
|
211
|
+
!params.noOutputTimedOut &&
|
|
212
|
+
!params.killIssuedByTimeout
|
|
213
|
+
? 0
|
|
214
|
+
: null)
|
|
215
|
+
); `
|
|
223
216
|
}),
|
|
224
217
|
createComponent(Spacing, {}),
|
|
225
218
|
createComponent(FunctionDeclaration, {
|
|
@@ -230,12 +223,12 @@ return [stdin, "pipe", "pipe"];`
|
|
|
230
223
|
}],
|
|
231
224
|
returnType: "boolean",
|
|
232
225
|
children: code`// SECURITY: never enable \`shell\` for argv-based execution.
|
|
233
|
-
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
234
|
-
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
235
|
-
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
236
|
-
// and validate/escape at the call site.
|
|
237
|
-
void params;
|
|
238
|
-
return false
|
|
226
|
+
// \`shell\` routes through cmd.exe on Windows, which turns untrusted argv values
|
|
227
|
+
// (like chat prompts passed as CLI args) into command-injection primitives.
|
|
228
|
+
// If you need a shell, use an explicit shell-wrapper argv (e.g. \`cmd.exe /c ...\`)
|
|
229
|
+
// and validate/escape at the call site.
|
|
230
|
+
void params;
|
|
231
|
+
return false; `
|
|
239
232
|
}),
|
|
240
233
|
createComponent(Spacing, {}),
|
|
241
234
|
createComponent(TSDoc, { heading: "The result of a spawn operation." }),
|