From ddb110764e074b1aa56c3b0ea1c02b8162f72b3c Mon Sep 17 00:00:00 2001 From: Maarten van Heusden <50550545+mmvanheusden@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:44:46 -0800 Subject: [PATCH] fix: fix paths with spaces on Windows --- downloader.js | 2 +- utils.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/downloader.js b/downloader.js index 041030df..992d57a1 100644 --- a/downloader.js +++ b/downloader.js @@ -67,7 +67,7 @@ function submitForm() { } else if (process.platform.includes("win")) { // if the OS is windows, run the batch file console.log(document.getElementById("os-dropdown").selectedIndex) - command = await executeCommandWithTerminal(`${platformpath()}${sep}run.bat`, terminal, os) + command = await executeCommandWithTerminal(`"${platformpath()}${sep}run.bat"`, terminal, os) } else if (process.platform.includes("darwin")) { //macOS } diff --git a/utils.js b/utils.js index 42767b39..f0f88751 100644 --- a/utils.js +++ b/utils.js @@ -137,10 +137,11 @@ function removeDir(dir,) { function unzip(file, target) { const {exec} = require("child_process") const path = require("path") + let finalPath = platformpath() + path.sep return new Promise((resolve, reject) => { if (process.platform.toString().includes("win")) { - const command = "powershell.exe -Command Expand-Archive -Path " + platformpath() + path.sep + file + " -Destination " + platformpath() + path.sep + target + const command = `powershell.exe -Command Expand-Archive -Path '${finalPath + file}' -Destination '${finalPath + target}'` exec(command, function (error) { if (error) { reject(error) @@ -148,7 +149,7 @@ function unzip(file, target) { } else resolve() }) } else { - const command = "unzip -o " + file + " -d ./" + target + "/" + const command = `unzip -o ${platformpath().replaceAll(" ", "\\ ") + path.sep + file} -d ${platformpath().replaceAll(" ", "\\ ") + path.sep + target}${path.sep}` exec(command, function (error) { if (error) { reject(error) @@ -286,7 +287,7 @@ async function executeCommandWithTerminal(command, terminal, os) { console.log(`os: ${os}`) console.log(`command: ${command}`) if (os === 0) { - cmd = `start cmd.exe /k '${command}'` + cmd = `start cmd.exe /k ${command}` } else if (os === 1) { cmd = `osascript -c 'tell application "Terminal" to do script '${command}'` } else if (os === 2) { @@ -401,7 +402,7 @@ dotnet ${platformpath().replaceAll(" ", "\\ ")}${sep}depotdownloader${sep}DepotD await fs.chmodSync(`${platformpath()}${sep}run.sh`, "755") // make it executable } else if (process.platform.includes("win")) { // if windows, write a batch script - let content = `dotnet ${platformpath()}${sep}depotdownloader${sep}DepotDownloader.dll ${userpass} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath} -max-servers 50 -max-downloads 16` + let content = `dotnet "${platformpath()}${sep}depotdownloader${sep}DepotDownloader.dll" ${userpass} -app ${appid} -depot ${depotid} -manifest ${manifestid} -dir ${finalPath} -max-servers 50 -max-downloads 16` await fs.writeFileSync(`${platformpath()}${sep}run.bat`, content) } else { /* macos */ }