Skip to content

Commit

Permalink
Merge pull request #35 from SavvySoftWorksLLC/sds/start_menu_icon
Browse files Browse the repository at this point in the history
Add program to start menu
  • Loading branch information
garyanewsome authored Sep 21, 2017
2 parents 3e50856 + 729a5fe commit bd513f4
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
36 changes: 34 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
{
"name": "savadoro",
"productName": "Savadoro",
"version": "0.2.2",
"version": "0.2.3",
"description": "Pomodoro Timer by SavvySoftWorks",
"main": "src/index.js",
"scripts": {
"start": "NODE_ENV=DEV electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"lint": "eslint src"
"lint": "eslint src",
"postinstall": "install-app-deps",
"start": "npm install && electron ./app",
"pack": "build --dir",
"dist": "build"
},
"build": {
"appId": "savvysoftworks.savadoro",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
]
},
"win": {
"target": "squirrel",
"icon": "src/assets/icons/Icon.png.ico"
}
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -61,6 +92,7 @@
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"electron-builder": "^19.27.7",
"electron-prebuilt-compile": "1.6.11",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.2",
Expand Down
50 changes: 50 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,56 @@ let mainWindow;

var path = require('path');

if(handleSquirrelEvent()) {
handleSquirrelEvent();
}

function handleSquirrelEvent() {
if (process.argv.length === 1) {
return false;
}

const ChildProcess = require('child_process');
const path = require('path');

const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = 'Savadoro';

const spawn = function(command, args) {
let spawnedProcess, error;

try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
} catch (error) {}

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]);
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;
}
};

const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
Expand Down

0 comments on commit bd513f4

Please sign in to comment.