Skip to content

Commit

Permalink
fix: prevent devtools from automatically opening on non-dev environments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmvanheusden committed Dec 8, 2023
1 parent 369bd80 commit 0c9d18e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 6 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ const createWindow = () => {
// and load the index.html of the app.
mainWindow.loadFile("index.html")

// Open the DevTools for debugging, only if not in production.
if (!app.isPackaged) {
mainWindow.webContents.openDevTools({mode: "detach"})
}
// @formatter:off
// Open the DevTools for debugging, only if not in production. This is removed for release by the build script (package.sh) because it's unreliable.
// disable formatting so the line always stays the same so sed can find it
// eslint-disable-next-line no-undef
if (!app.isPackaged) mainWindow.webContents.openDevTools({mode: "detach"})
// @formatter:on
}

// This method will be called when Electron has finished
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steamdepotdownloadergui",
"version": "2.3.0",
"version": "2.3.1",
"description": "DepotDownloader Electron frontend",
"main": "main.js",
"scripts": {
Expand Down
18 changes: 16 additions & 2 deletions package.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#!/usr/bin/env bash
set -e
version=`jq '.version' package.json`
version="${version//\"}"
echo "version = ${version}"
echo "version that will be build is ${version}"
rm -rf ./dist/

# Disable DevTools for release, because it's unreliable
original_line=$(sed -n '/if (!app.isPackaged) mainWindow.webContents.openDevTools({mode: "detach"})/p' main.js)
# original_line has 1 tab too much, so we remove it
original_line="${original_line// /}"
sed -i 's/if (!app.isPackaged) mainWindow.webContents.openDevTools({mode: "detach"})/\/\/REMOVED FOR RELEASE./g' main.js


npm run build
mkdir -p ./dist/release-ready

cp ./dist/SteamDepotDownloaderGUI*.exe ./dist/release-ready/SteamDepotDownloaderGUI-windows-"${version}".exe
cp `ls -d1 dist/* | grep -E "SteamDepotDownloaderGUI-[0-9]+\.[0-9]+\.[0-9]+\.AppImage"` ./dist/release-ready/SteamDepotDownloaderGUI-linux-"${version}"-x64.AppImage
cp `ls -d1 dist/* | grep -E "steamdepotdownloadergui-[0-9]+\.[0-9]+\.[0-9]+\.zip"` ./dist/release-ready/SteamDepotDownloaderGUI-linux-"${version}"-x64.zip
cp `ls -d1 dist/* | grep -E "SteamDepotDownloaderGUI-[0-9]+\.[0-9]+\.[0-9]+\-arm64.AppImage"` ./dist/release-ready/SteamDepotDownloaderGUI-linux-"${version}"-arm64.AppImage
cp `ls -d1 dist/* | grep -E "steamdepotdownloadergui-[0-9]+\.[0-9]+\.[0-9]+\-arm64.zip"` ./dist/release-ready/SteamDepotDownloaderGUI-linux-"${version}"-arm64.zip
echo "done!"
echo "done building!"
echo "reverting changes to main.js"
sed -i "s|\/\/REMOVED FOR RELEASE.|$original_line|g" main.js

0 comments on commit 0c9d18e

Please sign in to comment.