Skip to content

Commit

Permalink
feat: add protonRunUrl command
Browse files Browse the repository at this point in the history
  • Loading branch information
pikdum committed May 28, 2023
1 parent 81dbfb4 commit 6233d2d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ $ ./vortex-linux setConfig STEAM_RUNTIME_PATH $HOME/.steam/steam/steamapps/commo
{
"STEAM_RUNTIME_PATH": "/home/pikdum/.steam/steam/steamapps/common/SteamLinuxRuntime_sniper"
}
$ ./vortex-linux protonRunUrl https://download.visualstudio.microsoft.com/download/pr/85473c45-8d91-48cb-ab41-86ec7abc1000/83cd0c82f0cde9a566bae4245ea5a65b/windowsdesktop-runtime-6.0.16-win-x64.exe /q
Running: /tmp/windowsdesktop-runtime-6.0.16-win-x64.exe /q
...
$ ./vortex-linux installVortex vortex-setup-1.8.3.exe
...
$ ./vortex-linux setupVortexDesktop
Expand Down
29 changes: 29 additions & 0 deletions src/lib/proton.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,32 @@ export const setProton = (protonBuild) => {
console.error("Error setting Proton:", error);
}
};

export const protonRunUrl = async (downloadUrl, args) => {
const tempFilePath = path.join(os.tmpdir(), path.basename(downloadUrl));

let command = tempFilePath;
if (args) {
command += ` ${args}`;
}

try {
// Download the file
const response = await fetch(downloadUrl);
if (!response.ok) {
throw new Error(
`Failed to download file (${response.status} ${response.statusText})`
);
}
await pipelineAsync(response.body, fs.createWriteStream(tempFilePath));

// Run protonRun with the command
console.log(`Running: ${command}`);
await protonRun(command);
} finally {
// Clean up the temporary file
if (fs.existsSync(tempFilePath)) {
fs.unlinkSync(tempFilePath);
}
}
};
9 changes: 8 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { program } from "commander";

import { downloadProton, setProton } from "./lib/proton.js";
import { downloadProton, setProton, protonRunUrl } from "./lib/proton.js";
import {
downloadVortex,
installVortex,
Expand Down Expand Up @@ -84,4 +84,11 @@ program
console.log(JSON.stringify(getConfig(), null, 2));
});

program
.command("protonRunUrl <downloadUrl> [args]")
.description("Download and run an .exe")
.action(async (downloadUrl, args) => {
await protonRunUrl(downloadUrl, args);
});

program.parse(process.argv);

0 comments on commit 6233d2d

Please sign in to comment.