Initial commit.

This commit is contained in:
Cameron Redmore 2025-05-19 11:40:56 +01:00
commit b022bca449
20 changed files with 7405 additions and 0 deletions

54
src/squirrelEvents.js Normal file
View file

@ -0,0 +1,54 @@
const { app } = require('electron');
const ChildProcess = require('child_process');
const path = require('path');
const fs = require('fs');
function handleSquirrelEvent() {
if (process.argv.length === 1) {
return false;
}
const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);
const spawn = function (command, args) {
let spawnedProcess;
try {
spawnedProcess = ChildProcess.spawn(command, args, { detached: true });
} catch (error) {
// Log error or handle appropriately
}
return spawnedProcess;
};
const spawnUpdate = function (args) {
return spawn(updateDotExe, args);
};
const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
spawnUpdate(['--createShortcut', exeName]);
const desktopShortcutPath = path.join(app.getPath('desktop'), `${exeName}.lnk`);
if (fs.existsSync(desktopShortcutPath)) {
fs.unlinkSync(desktopShortcutPath);
}
setTimeout(app.quit, 1000);
return true;
case '--squirrel-uninstall':
spawnUpdate(['--removeShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-obsolete':
app.quit();
return true;
}
return false; // Ensure a boolean is always returned
}
module.exports = { handleSquirrelEvent };