Skip to content

Commit

Permalink
Build scripts: Replace single quotes with double quotes for compatibi…
Browse files Browse the repository at this point in the history
…lity with Windows (#26408)
  • Loading branch information
alexslavr authored Jan 5, 2024
1 parent 5239395 commit a336967
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions build/common/shell-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { mapOptions } from './shell-utils';
describe('shell utils', () => {

test.each([
{ options: { a: 123 }, map: { a: 'x' }, expected: `x='123'` },
{ options: { a: 'def' }, map: { a: 'x' }, expected: `x='def'` },
{ options: { a: 123 }, map: { a: 'x' }, expected: `x="123"` },
{ options: { a: 'def' }, map: { a: 'x' }, expected: `x="def"` },
{ options: { a: true }, map: { a: { kind: 'flag', alias: 'x' } }, expected: 'x' },
{ options: { a: false }, map: { a: { kind: 'flag', alias: 'x' } }, expected: '' },
{ options: { b: 123, a: true, c: 'def' }, map: { a: { kind: 'flag', alias: 'x' }, b: 'y', c: 'z' }, expected: `y='123' x z='def'` },
{ options: { b: 123, a: false, c: 'def' }, map: { a: { kind: 'flag', alias: 'x' }, b: 'y', c: 'z' }, expected: `y='123' z='def'` },
{ options: { b: 123, a: true, c: 'def' }, map: { a: { kind: 'flag', alias: 'x' }, b: 'y', c: 'z' }, expected: `y="123" x z="def"` },
{ options: { b: 123, a: false, c: 'def' }, map: { a: { kind: 'flag', alias: 'x' }, b: 'y', c: 'z' }, expected: `y="123" z="def"` },
] as const)('mapOptions', ({ options, map, expected }) => {
expect(mapOptions(options, map as any)).toBe(expected);
});
Expand Down
4 changes: 2 additions & 2 deletions build/common/shell-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ function mapKeyValue(key: string, value: unknown, map: Record<string, Mapping>):
const mapping = key in map ? map[key] : undefined;
if (mapping !== undefined) {
if (typeof (mapping) === 'string') {
return `${mapping}='${value}'`;
return `${mapping}="${value}"`;
}

if (mapping.kind === 'flag') {
return value ? `${mapping.alias}` : '';
}
}

return `${key}='${value}'`;
return `${key}="${value}"`;
}

export function mapOptions<TOptions extends Record<string, any>>(options: TOptions, map: Record<keyof TOptions, Mapping>): string {
Expand Down

0 comments on commit a336967

Please sign in to comment.