claude-dev-env 8.107.0 → 8.107.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.
|
@@ -201,15 +201,20 @@ export function shouldInstallMarketplacePlugin(
|
|
|
201
201
|
return environment[spec.optOutVariable] !== '0';
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
const BARE_COMMAND_NAME_PATTERN = /^[A-Za-z0-9_][\w.-]*$/;
|
|
205
|
+
|
|
204
206
|
/**
|
|
205
207
|
* Build the process launch one platform needs to run a host command.
|
|
206
208
|
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
* through `cmd.exe /d /s /c`
|
|
210
|
-
*
|
|
211
|
-
* why the line is passed verbatim rather than
|
|
212
|
-
*
|
|
209
|
+
* The hosts, `claude`, `codex` and the `npm` that installs Pele, ship on
|
|
210
|
+
* Windows as a `.cmd` shim. Node's synchronous spawn rejects a batch file with
|
|
211
|
+
* `EINVAL` unless a shell runs it, so Windows goes through `cmd.exe /d /s /c`
|
|
212
|
+
* with the whole command line as one verbatim argument. A path carries its own
|
|
213
|
+
* quotes inside that line, which is why the line is passed verbatim rather than
|
|
214
|
+
* quoted again by Node. A bare name stays unquoted because `cmd.exe` hands a
|
|
215
|
+
* quoted bare name to a shim as `%0`, and the shim then resolves `%~dp0`
|
|
216
|
+
* against the working directory instead of its own folder. Every other
|
|
217
|
+
* platform launches the executable directly.
|
|
213
218
|
*
|
|
214
219
|
* @param {string} executable The host command, a bare name or a path.
|
|
215
220
|
* @param {string[]} commandArguments The arguments after the executable.
|
|
@@ -226,7 +231,8 @@ export function hostCommandInvocation(
|
|
|
226
231
|
if (platform !== 'win32') {
|
|
227
232
|
return { file: executable, args: [...commandArguments], windowsVerbatimArguments: false };
|
|
228
233
|
}
|
|
229
|
-
const
|
|
234
|
+
const launchedExecutable = BARE_COMMAND_NAME_PATTERN.test(executable) ? executable : `"${executable}"`;
|
|
235
|
+
const commandLine = [launchedExecutable, ...commandArguments].join(' ');
|
|
230
236
|
return {
|
|
231
237
|
file: environment.ComSpec || 'cmd.exe',
|
|
232
238
|
args: ['/d', '/s', '/c', `"${commandLine}"`],
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
removeStaleMarketplaceClone,
|
|
20
20
|
removeRetiredMarketplacePlugins,
|
|
21
21
|
restartNotice,
|
|
22
|
+
runHostCommand,
|
|
22
23
|
shouldInstallMarketplacePlugin,
|
|
23
24
|
} from './install-pstack-plugin.mjs';
|
|
24
25
|
|
|
@@ -265,11 +266,37 @@ test('Windows launches the host command through cmd.exe, which alone can run a .
|
|
|
265
266
|
'/d',
|
|
266
267
|
'/s',
|
|
267
268
|
'/c',
|
|
268
|
-
`"
|
|
269
|
+
`"claude plugin install ${PSTACK_PLUGIN_IDENTIFIER}"`,
|
|
269
270
|
]);
|
|
270
271
|
assert.equal(invocation.windowsVerbatimArguments, true);
|
|
271
272
|
});
|
|
272
273
|
|
|
274
|
+
test('a bare Windows command name stays unquoted so a .cmd shim finds its own folder through %~dp0', () => {
|
|
275
|
+
const invocation = hostCommandInvocation('npm', ['view', 'pele', 'version'], 'win32', WINDOWS_ENVIRONMENT);
|
|
276
|
+
assert.equal(invocation.args.at(-1), '"npm view pele version"');
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test('npm runs from a folder away from its own install on Windows', { skip: process.platform !== 'win32' }, () => {
|
|
280
|
+
const workingDirectory = mkdtempSync(join(tmpdir(), 'cde-npm-launch-'));
|
|
281
|
+
try {
|
|
282
|
+
const outcome = runHostCommand('npm', ['--version'], { cwd: workingDirectory });
|
|
283
|
+
assert.equal(outcome.status, 0, outcome.stderr);
|
|
284
|
+
assert.match(outcome.stdout, /^\d+\.\d+\.\d+/);
|
|
285
|
+
} finally {
|
|
286
|
+
rmSync(workingDirectory, { recursive: true, force: true });
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test('a Windows executable name with a shell metacharacter stays quoted', () => {
|
|
291
|
+
const invocation = hostCommandInvocation('npm&calc', ['view'], 'win32', WINDOWS_ENVIRONMENT);
|
|
292
|
+
assert.equal(invocation.args.at(-1), '""npm&calc" view"');
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test('a Windows executable name that is a dot path or starts with a dash stays quoted', () => {
|
|
296
|
+
assert.equal(hostCommandInvocation('..', ['view'], 'win32', WINDOWS_ENVIRONMENT).args.at(-1), '"".." view"');
|
|
297
|
+
assert.equal(hostCommandInvocation('-npm', ['view'], 'win32', WINDOWS_ENVIRONMENT).args.at(-1), '""-npm" view"');
|
|
298
|
+
});
|
|
299
|
+
|
|
273
300
|
test('a Windows executable path holding a space stays one quoted token', () => {
|
|
274
301
|
const invocation = hostCommandInvocation(
|
|
275
302
|
'C:\\Program Files\\nodejs\\claude.cmd',
|