tidy electron files, they were starting to annoy me

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-05-22 19:21:52 +01:00
parent 73ec3e1f4d
commit 911c3bcf6e
4 changed files with 107 additions and 176 deletions

View file

@ -16,30 +16,30 @@ limitations under the License.
const path = require('path');
const spawn = require('child_process').spawn;
const app = require('electron').app;
const {app} = require('electron');
function run_update_exe(args, done) {
function runUpdateExe(args, done) {
// Invokes Squirrel's Update.exe which will do things for us like create shortcuts
// Note that there's an Update.exe in the app-x.x.x directory and one in the parent
// directory: we need to run the one in the parent directory, because it discovers
// information about the app by inspecting the directory it's run from.
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
console.log('Spawning `%s` with args `%s`', updateExe, args);
console.log(`Spawning '${updateExe}' with args '${args}'`);
spawn(updateExe, args, {
detached: true
detached: true,
}).on('close', done);
};
}
function check_squirrel_hooks() {
if (process.platform != 'win32') return false;
function checkSquirrelHooks() {
if (process.platform !== 'win32') return false;
const cmd = process.argv[1];
const target = path.basename(process.execPath);
if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
run_update_exe(['--createShortcut=' + target + ''], app.quit);
runUpdateExe(['--createShortcut=' + target + ''], app.quit);
return true;
} else if (cmd === '--squirrel-uninstall') {
run_update_exe(['--removeShortcut=' + target + ''], app.quit);
runUpdateExe(['--removeShortcut=' + target + ''], app.quit);
return true;
} else if (cmd === '--squirrel-obsolete') {
app.quit();
@ -48,4 +48,4 @@ function check_squirrel_hooks() {
return false;
}
module.exports = check_squirrel_hooks;
module.exports = checkSquirrelHooks;