From a2c4e9c104936501a692697ecdd71e8ce4fe9ff9 Mon Sep 17 00:00:00 2001
From: askiiart <dev@askiiart.net>
Date: Sun, 23 Feb 2025 14:06:31 -0600
Subject: [PATCH] fix tee running before jq reads the file

---
 build.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/build.sh b/build.sh
index a791605..e7217ab 100755
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,8 @@
 #!/usr/bin/env bash
 set -euo pipefail
+
+# install deps
+apt update && apt install jq -y
 npm install -g web-ext pnpm
 
 git clone --depth 1 https://github.com/Vendicated/Vencord
@@ -11,7 +14,13 @@ pnpm run buildWeb
 
 # change id
 cd ./dist/
-jq '.browser_specific_settings.gecko.id = "vencord-firefox@askiiart.net"' ./firefox-unpacked/manifest.json >./firefox-unpacked/manifest.json
+# can't just `tee` it directly into it, otherwise tee will erase all contents of the file, *then* jq will run
+# (same for redirecting the output ofc)
+tmpfile=$(mktemp)
+jq '.browser_specific_settings.gecko.id = "vencord-firefox@askiiart.net"' ./firefox-unpacked/manifest.json -c >$tmpfile
+mv $tmpfile ./firefox-unpacked/manifest.json
+
+# build it to an extension or whatever idk
 web-ext build -s ./firefox-unpacked/
 
 # move to /misc and set version