aboutsummaryrefslogtreecommitdiff
path: root/src/ipcMain/updater
diff options
context:
space:
mode:
authorA user <pedro.santos.cartaxo@gmail.com>2022-12-02 12:55:53 -0300
committerGitHub <noreply@github.com>2022-12-02 16:55:53 +0100
commit62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc (patch)
tree381d6f7420fc8ead35ce1dca09ef79df98ab8ce9 /src/ipcMain/updater
parent41dddc9eee6f19fb5055545811aff1e282790a9c (diff)
downloadVencord-62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc.tar.gz
Vencord-62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc.tar.bz2
Vencord-62b2acebe6806c7b0e2ca6a43c6b2419a627b8dc.zip
Add support for Flatpak for Git updating (#274)
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/ipcMain/updater')
-rw-r--r--src/ipcMain/updater/git.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/ipcMain/updater/git.ts b/src/ipcMain/updater/git.ts
index 07c94cb..20cc5b1 100644
--- a/src/ipcMain/updater/git.ts
+++ b/src/ipcMain/updater/git.ts
@@ -28,10 +28,13 @@ const VENCORD_SRC_DIR = join(__dirname, "..");
const execFile = promisify(cpExecFile);
+const isFlatpak = Boolean(process.env.FLATPAK_ID?.includes("discordapp") || process.env.FLATPAK_ID?.includes("Discord"));
+
function git(...args: string[]) {
- return execFile("git", args, {
- cwd: VENCORD_SRC_DIR
- });
+ const opts = { cwd: VENCORD_SRC_DIR };
+
+ if (isFlatpak) return execFile("flatpak-spawn", ["--host", "git", ...args], opts);
+ else return execFile("git", args, opts);
}
async function getRepo() {
@@ -61,9 +64,13 @@ async function pull() {
}
async function build() {
- const res = await execFile("node", ["scripts/build/build.mjs"], {
- cwd: VENCORD_SRC_DIR
- });
+ const opts = { cwd: VENCORD_SRC_DIR };
+
+ let res;
+
+ if (isFlatpak) res = await execFile("flatpak-spawn", ["--host", "node", "scripts/build/build.mjs"], opts);
+ else res = await execFile("node", ["scripts/build/build.mjs"], opts);
+
return !res.stderr.includes("Build failed");
}