Skip to content

Commit 40d5fb3

Browse files
committed
refactor: fix tests
1 parent 6bec56f commit 40d5fb3

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

packages/utils/src/lib/command.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ export function formatEnvValue(value: string): string {
3535
}
3636

3737
/**
38-
* Builds a command string by escaping arguments that contain spaces, quotes, or other special characters.
38+
* Builds a command string by joining arguments with spaces.
3939
*
4040
* @param {string} command - The base command to execute.
4141
* @param {string[]} args - Array of command arguments.
42-
* @returns {string} - The complete command string with properly escaped arguments.
42+
* @returns {string} - The complete command string with joined arguments.
4343
*/
4444
export function buildCommandString(
4545
command: string,

packages/utils/src/lib/command.unit.test.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,41 +189,39 @@ describe('buildCommandString', () => {
189189
expect(result).toBe('npm install --save-dev vitest');
190190
});
191191

192-
it('should escape arguments containing spaces', () => {
192+
it('should handle arguments containing spaces', () => {
193193
const command = 'code';
194194
const args = ['My Project/index.js'];
195195
const result = buildCommandString(command, args);
196-
expect(result).toBe('code "My Project/index.js"');
196+
expect(result).toBe('code My Project/index.js');
197197
});
198198

199-
it('should escape arguments containing double quotes', () => {
199+
it('should handle arguments containing double quotes', () => {
200200
const command = 'echo';
201201
const args = ['Hello "World"'];
202202
const result = buildCommandString(command, args);
203-
expect(result).toBe('echo "Hello \\"World\\""');
203+
expect(result).toBe('echo Hello "World"');
204204
});
205205

206-
it('should escape arguments containing single quotes', () => {
206+
it('should handle arguments containing single quotes', () => {
207207
const command = 'echo';
208208
const args = ["Hello 'World'"];
209209
const result = buildCommandString(command, args);
210-
expect(result).toBe('echo "Hello \'World\'"');
210+
expect(result).toBe("echo Hello 'World'");
211211
});
212212

213213
it('should handle mixed arguments with and without special characters', () => {
214214
const command = 'mycommand';
215215
const args = ['simple', 'with spaces', '--flag', 'with "quotes"'];
216216
const result = buildCommandString(command, args);
217-
expect(result).toBe(
218-
'mycommand simple "with spaces" --flag "with \\"quotes\\""',
219-
);
217+
expect(result).toBe('mycommand simple with spaces --flag with "quotes"');
220218
});
221219

222220
it('should handle arguments with multiple types of quotes', () => {
223221
const command = 'test';
224222
const args = ['arg with "double" and \'single\' quotes'];
225223
const result = buildCommandString(command, args);
226-
expect(result).toBe('test "arg with \\"double\\" and \'single\' quotes"');
224+
expect(result).toBe('test arg with "double" and \'single\' quotes');
227225
});
228226

229227
it('should handle objects with undefined', () => {
@@ -243,6 +241,6 @@ describe('buildCommandString', () => {
243241
const command = 'test';
244242
const args = [' '];
245243
const result = buildCommandString(command, args);
246-
expect(result).toBe('test " "');
244+
expect(result).toBe('test ');
247245
});
248246
});

0 commit comments

Comments
 (0)