Skip to content

Commit 188f6d0

Browse files
committed
fix(@angular/cli): use spawn with args array on Windows and remove manual quoting tests
1 parent 5ed1576 commit 188f6d0

2 files changed

Lines changed: 3 additions & 32 deletions

File tree

packages/angular/cli/src/commands/add/registry-validation.spec.ts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('registry validation', () => {
2222

2323
it('should not match safe URL characters', () => {
2424
expect(SHELL_METACHARACTERS.test('https://registry.example.com')).toBe(false);
25-
expect(SHELL_METACHARACTERS.test('http://registry.example.com/path')).toBe(false);
26-
expect(SHELL_METACHARACTERS.test('https://registry.example.com:8080')).toBe(false);
25+
expect(SHELL_METACHARACTERS.test('http://registry.example.com:8080')).toBe(false);
26+
expect(SHELL_METACHARACTERS.test('https://registry.example.com/path')).toBe(false);
2727
});
2828
});
2929

@@ -61,28 +61,4 @@ describe('registry validation', () => {
6161
);
6262
});
6363
});
64-
65-
describe('Windows shell quoting', () => {
66-
it('should wrap args in double quotes', () => {
67-
const command = 'npm';
68-
const args = ['--registry', 'https://registry.example.com'];
69-
const result = `${command} ${args
70-
.map((a) => `"${String(a).replace(/"/g, '\\"')}"`)
71-
.join(' ')}`;
72-
expect(result).toBe(
73-
'npm "--registry" "https://registry.example.com"',
74-
);
75-
});
76-
77-
it('should escape inner double quotes', () => {
78-
const command = 'npm';
79-
const args = ['--registry', 'https://example.com?key="value"'];
80-
const result = `${command} ${args
81-
.map((a) => `"${String(a).replace(/"/g, '\\"')}"`)
82-
.join(' ')}`;
83-
expect(result).toBe(
84-
'npm "--registry" "https://example.com?key=\\"value\\""',
85-
);
86-
});
87-
});
8864
});

packages/angular/cli/src/package-managers/host.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,7 @@ export const NodeJS_HOST: Host = {
157157
cwd: options.cwd,
158158
env,
159159
} satisfies SpawnOptions;
160-
const childProcess = isWin32
161-
? spawn(
162-
`${command} ${args.map((a) => `"${String(a).replace(/"/g, '\\"')}"`).join(' ')}`,
163-
spawnOptions,
164-
)
165-
: spawn(command, args, spawnOptions);
160+
const childProcess = spawn(command, args, spawnOptions);
166161

167162
let stdout = '';
168163
childProcess.stdout?.on('data', (data) => (stdout += data.toString()));

0 commit comments

Comments
 (0)