Skip to content

Instantly share code, notes, and snippets.

@iCodeForBananas
Created February 1, 2016 19:22
Show Gist options
  • Select an option

  • Save iCodeForBananas/db7f7f94ed9dd1c362f5 to your computer and use it in GitHub Desktop.

Select an option

Save iCodeForBananas/db7f7f94ed9dd1c362f5 to your computer and use it in GitHub Desktop.
'use strict'
const electron = require('electron')
const updater = require('electron-updater')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1200,
height: 800,
title: 'Code Sketcher',
center: true,
titleBarStyle: 'hidden-inset'
})
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html')
// Open the DevTools.
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
updater.on('error', function (err) {
// todo: manually handle errors here in addition to default logger behavior...
console.error(err)
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
updater.on('ready', createWindow)
updater.on('updateRequired', function() {
app.quit()
})
updater.on('updateAvailable', function() {
if(mainWindow) {
mainWindow.webContents.send('updateAvailable')
}
})
updater.on('updateInProgress', function() {
console.log('Update already in progress...')
console.log('If this is stuck here clean out your application update directory.')
})
updater.start()
})
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
{
"name": "CodeSketcher",
"main": "main.js",
"version": "0.0.4",
"scripts": {
"start": "electron main.js",
"package": "electron-packager ./ CodeSketcher --all --out ~/Desktop/CodeSketcher --version 0.30.2 --overwrite"
},
"devDependencies": {
"del": "^2.2.0",
"electron-prebuilt": "^0.36.4",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-babel": "^6.1.1",
"gulp-cache": "^0.4.1",
"gulp-concat": "^2.6.0",
"gulp-cssnano": "^2.1.0",
"gulp-imagemin": "^2.4.0",
"gulp-jshint": "^2.0.0",
"gulp-livereload": "^3.8.1",
"gulp-notify": "^2.2.0",
"gulp-rename": "^1.2.2",
"gulp-ruby-sass": "^2.0.6",
"gulp-run": "^1.6.12",
"gulp-uglify": "^1.5.1",
"gulp-watch": "^4.3.5"
},
"dependencies": {
"angular": "^1.4.8",
"angular-elastic": "^2.5.1",
"angular-highlightjs": "^0.5.1",
"angular-hotkeys": "^1.6.0",
"angular-loading-bar": "^0.8.0",
"angular-local-storage": "^0.2.2",
"angular-moment": "1.0.0-beta.3",
"angular-sanitize": "^1.4.5",
"angular-ui-bootstrap": "^1.1.0",
"angular-ui-router": "^0.2.15",
"angular-ui-sortable": "^0.13.4",
"babel": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"electron-plugins": "0.0.4",
"electron-updater": "github:vj3k0/electron-updater",
"highlight.js": "^9.1.0",
"image-size": "^0.4.0",
"jquery": "^2.2.0",
"lodash": "^4.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment