Skip to content

Commit

Permalink
refactor: Use .map in escapeCommandLine
Browse files Browse the repository at this point in the history
  • Loading branch information
xymopen committed Jan 9, 2025
1 parent 7b8c801 commit 6b9cbea
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions extensions/npm/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,13 @@ export function getTaskName(script: string, relativePath: string | undefined) {
}

function escapeCommandLine(cmd: string[]): (string | ShellQuotedString)[] {
const result: (string | ShellQuotedString)[] = new Array(cmd.length);
for (let i = 0; i < cmd.length; i++) {
if (/\s/.test(cmd[i])) {
result[i] = { value: cmd[i], quoting: cmd[i].includes('--') ? ShellQuoting.Weak : ShellQuoting.Strong };
return cmd.map(arg => {
if (/\s/.test(arg)) {
return { value: arg, quoting: arg.includes('--') ? ShellQuoting.Weak : ShellQuoting.Strong };
} else {
result[i] = cmd[i];
return arg;
}
}
return result;
});
}

function getRelativePath(rootUri: Uri, packageJsonUri: Uri): string {
Expand Down

0 comments on commit 6b9cbea

Please sign in to comment.