Skip to content

Commit 7e534be

Browse files
authored
chore(smoke-tests): windows fixes (#7038)
* Only remove windows installer if it exists * Warn if removal fails * Passing SQUIRREL_TEMP to sandbox the install * Use --checkInstall to silence the Update.exe * Add a debug statement with the executable * Pass --silent directly
1 parent bd10dc4 commit 7e534be

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

packages/compass-smoke-tests/src/installers/windows-setup.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function installWindowsSetup({
2424
kind,
2525
filepath,
2626
buildInfo,
27+
sandboxPath,
2728
}: InstallablePackage): InstalledAppInfo {
2829
assert.equal(kind, 'windows_setup');
2930
const appName = buildInfo.installerOptions.name;
@@ -62,7 +63,18 @@ export function installWindowsSetup({
6263
debug(`Running command to uninstall: ${uninstallCommand}`);
6364
cp.execSync(uninstallCommand, { stdio: 'inherit' });
6465
// Removing the any remaining files manually
65-
fs.rmSync(installLocation, { recursive: true, force: true });
66+
try {
67+
if (fs.existsSync(installLocation)) {
68+
debug(`Removing installer: ${installLocation}`);
69+
fs.rmSync(installLocation, { recursive: true, force: true });
70+
}
71+
} catch (error) {
72+
console.warn(
73+
`Failed to remove install location ${installLocation}: ${
74+
error instanceof Error ? error.message : error
75+
}`
76+
);
77+
}
6678
}
6779
}
6880

@@ -72,7 +84,20 @@ export function installWindowsSetup({
7284
console.warn(
7385
"Installing globally, since we haven't discovered a way to specify an install path"
7486
);
75-
execute(filepath, []);
87+
execute(
88+
filepath,
89+
[
90+
// Args are passed through to the Update.exe https://github.com/Squirrel/Squirrel.Windows/blob/51f5e2cb01add79280a53d51e8d0cfa20f8c9f9f/src/Setup/winmain.cpp#L125
91+
// See options in https://github.com/Squirrel/Squirrel.Windows/blob/51f5e2cb01add79280a53d51e8d0cfa20f8c9f9f/src/Update/StartupOption.cs
92+
'--silent',
93+
],
94+
{
95+
env: {
96+
// See https://github.com/Squirrel/Squirrel.Windows/blob/51f5e2cb01add79280a53d51e8d0cfa20f8c9f9f/src/Setup/UpdateRunner.cpp#L173C40-L173C54
97+
SQUIRREL_TEMP: sandboxPath,
98+
},
99+
}
100+
);
76101

77102
const entry = queryRegistry();
78103
assert(entry !== null, 'Expected an entry in the registry after installing');
@@ -84,6 +109,7 @@ export function installWindowsSetup({
84109
const appExecutablePath = path.resolve(appPath, `${appName}.exe`);
85110

86111
// Check if the app executable exists after installing
112+
debug('Using app executable path: %s', appExecutablePath);
87113
assert(
88114
fs.existsSync(appExecutablePath),
89115
`Expected ${appExecutablePath} to exist`

0 commit comments

Comments
 (0)