Skip to content

Commit 6be3f37

Browse files
addaleaxmabaasit
authored andcommitted
fix(compass-preferences-model): ignore squirrel options (#3802)
1 parent 593aec1 commit 6be3f37

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

packages/compass-preferences-model/src/global-config.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ describe('Global config file handling', function () {
4444
});
4545
});
4646

47+
it('ignores startup with --squirrel-firstrun', async function () {
48+
const result = await parseAndValidateGlobalPreferences({
49+
globalConfigPaths: [],
50+
argv: ['--squirrel-firstrun'],
51+
});
52+
expect(result).to.deep.equal({
53+
global: {},
54+
cli: {},
55+
preferenceParseErrors: [],
56+
});
57+
});
58+
4759
it('parses global config files (YAML)', async function () {
4860
const file = path.join(tmpdir, 'config');
4961
await fs.writeFile(file, 'enableMaps: false\n');

packages/compass-preferences-model/src/global-config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ function parseCliArgs(argv: string[]): unknown {
130130
result.positionalArguments = result._;
131131
}
132132
delete (result as any)._;
133+
for (const key of Object.keys(result)) {
134+
// Remove command line flags added by the Windows .exe installer.
135+
if (key.startsWith('squirrel')) delete (result as any)[key];
136+
}
133137
return result;
134138
}
135139

@@ -220,11 +224,12 @@ export async function parseAndValidateGlobalPreferences(
220224
}
221225
const cliPreferences = parseCliArgs(argv);
222226
if (cliPreferences && typeof cliPreferences === 'object') {
223-
// Remove positional arguments and common Electron/Chromium flags
224-
// that we want to allow.
225-
const ignoreFlags = ['disableGpu', 'sandbox'];
226-
for (const flag of ignoreFlags) {
227-
delete (cliPreferences as Record<string, unknown>)[flag];
227+
// Remove common Electron/Chromium/Installer flags that we want to allow.
228+
const ignoreFlags = /^(disableGpu$|sandbox$|squirrel)/;
229+
for (const key of Object.keys(cliPreferences)) {
230+
if (key.match(ignoreFlags)) {
231+
delete (cliPreferences as Record<string, unknown>)[key];
232+
}
228233
}
229234
}
230235

0 commit comments

Comments
 (0)