Installer: add custom path option (#77)

This commit is contained in:
Ven 2022-10-22 02:36:49 +02:00 committed by GitHub
parent 0da02e009c
commit 23d4cae123
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,13 +95,12 @@ async function getMenuItem(installations) {
info, info,
})); }));
if (menuItems.length === 0) {
console.log("No Discord installations found.");
process.exit(1);
}
const result = await menu( const result = await menu(
[...menuItems, { title: "Exit without patching", exit: true }], [
...menuItems,
{ title: "Specify custom path", info: "custom" },
{ title: "Exit without patching", exit: true }
],
{ {
header: "Select a Discord installation to patch:", header: "Select a Discord installation to patch:",
border: true, border: true,
@ -116,6 +115,33 @@ async function getMenuItem(installations) {
process.exit(0); process.exit(0);
} }
if (result.info === "custom") {
const customPath = await question("Please enter the path: ");
if (!customPath || !fs.existsSync(customPath)) {
console.log("No such Path or not specifed.");
process.exit();
}
const resourceDir = path.join(customPath, "resources");
if (!fs.existsSync(path.join(resourceDir, "app.asar"))) {
console.log("Unsupported Install. resources/app.asar not found");
process.exit();
}
const appDir = path.join(resourceDir, "app");
result.info = {
branch: "unknown",
patched: fs.existsSync(appDir),
location: customPath,
versions: [{
path: appDir,
name: null
}],
arch: process.platform === "linux" ? "linux" : "win32",
isFlatpak: false,
};
}
if (result.info.patched) { if (result.info.patched) {
const answer = await question( const answer = await question(
"This installation has already been modified. Overwrite? [Y/n]: " "This installation has already been modified. Overwrite? [Y/n]: "