Skip to content

PowerShell/Windows support #1

@GiromettaMarco

Description

@GiromettaMarco

First of all, I would like to thank you for sharing your work.

I'm trying to use the extension on a Windows machine with PowerShell 7 and I've encountered some issues that prevent the extension from working:

Commands (and arguments) are wrapped in double quotes

gutteraid/src/extension.ts

Lines 450 to 452 in e93c8be

if (process.platform === 'win32') {
// Escape quotes and backslashes for Windows cmd/PowerShell
return `"${arg.replace(/"/g, '""').replace(/\\/g, '\\\\')}"`;

This causes commands to be evaluated as strings.

Possible fix:

- 	return `"${arg.replace(/"/g, '""').replace(/\\/g, '\\\\')}"`;
+ 	return `${arg.replace(/"/g, '""').replace(/\\/g, '\\\\')}`;

PowerShell replaced %ERRORLEVEL% with $LASTEXITCODE

gutteraid/src/extension.ts

Lines 465 to 466 in e93c8be

if (process.platform === 'win32') {
fullCommand = `${command} && echo %ERRORLEVEL% > "${tempFile}"`;

Possible fix:

see below

AND Operator (&&) skips the rest of the script if the user script fails

In reference to the same line of code as above, the temp file would never be created if the user script fails (for example if the script runs a test and the test fails). && could be replaced with ; (just like in the default script).

Possible fix:

- 	fullCommand = `${command} && echo %ERRORLEVEL% > "${tempFile}"`; 
+ 	fullCommand = `${command}; echo $LASTEXITCODE > "${tempFile}"`;

I can submit a PR if needed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions