From 771dd83c166d960dec4c6298a9dbfb1ac0deb0a2 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 4 Oct 2021 10:25:15 +0200 Subject: [PATCH] fix: installation with folders which contain spaces (#9275) --- src/utils/dependencies.ts | 2 +- src/utils/registry.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/utils/dependencies.ts b/src/utils/dependencies.ts index 0eaa7b091b..299b39ec02 100644 --- a/src/utils/dependencies.ts +++ b/src/utils/dependencies.ts @@ -39,7 +39,7 @@ export type DependencyGroup = 'chromium' | 'firefox' | 'webkit' | 'tools'; export async function installDependenciesWindows(targets: Set) { if (targets.has('chromium')) { - const { code } = await utils.spawnAsync('powershell.exe', [path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' }); + const { code } = await utils.spawnAsync('powershell.exe', ['-File', path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' }); if (code !== 0) throw new Error('Failed to install windows dependencies!'); } diff --git a/src/utils/registry.ts b/src/utils/registry.ts index 3efc2a58a3..9323533249 100644 --- a/src/utils/registry.ts +++ b/src/utils/registry.ts @@ -632,8 +632,14 @@ export class Registry { const scriptName = scripts[process.platform as 'linux' | 'darwin' | 'win32']; if (!scriptName) throw new Error(`Cannot install ${channel} on ${process.platform}`); - const shell = scriptName.endsWith('.ps1') ? 'powershell.exe' : 'bash'; - const { code } = await spawnAsync(shell, [path.join(BIN_PATH, scriptName), ...scriptArgs], { cwd: BIN_PATH, stdio: 'inherit' }); + const isPowerShell = scriptName.endsWith('.ps1'); + const shell = isPowerShell ? 'powershell.exe' : 'bash'; + const args = [ + ...(isPowerShell ? ['-File'] : []), + path.join(BIN_PATH, scriptName), + ...scriptArgs + ]; + const { code } = await spawnAsync(shell, args, { cwd: BIN_PATH, stdio: 'inherit' }); if (code !== 0) throw new Error(`Failed to install ${channel}`); }