From ac2504b8b3344fc4c78b52855f00bbef5f1bfe2f Mon Sep 17 00:00:00 2001 From: Matt Haggard Date: Fri, 3 Feb 2017 11:03:35 -0700 Subject: [PATCH] Add logging --- README.md | 2 ++ main.js | 19 +++++++++++++------ package.json | 7 +++++-- publish.sh | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7e21669..dd49192 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ This repo contains the bare minimum code to have an auto-updating Electron app using [`electron-updater`](https://github.com/electron-userland/electron-builder/tree/master/packages/electron-updater) with releases stored on GitHub. +**NOTE:** If you want to run through this whole process, you will need to fork this repo on GitHub and replace all instances of `iffy` with your GitHub username before doing the following steps. + 1. First, install necessary dependencies with: npm install diff --git a/main.js b/main.js index bcdb6ee..27ed04b 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,18 @@ // See LICENSE for details. const {app, BrowserWindow, Menu, protocol} = require('electron'); -var electron = require('electron'); +const log = require('electron-log'); +const {autoUpdater} = require("electron-updater"); + +//------------------------------------------------------------------- +// Logging +// +// This logging setup is not required for auto-updates to work, +// but it sure makes debugging easier :) +//------------------------------------------------------------------- +autoUpdater.logger = log; +autoUpdater.logger.transports.file.level = 'info'; +log.info('App starting...'); //------------------------------------------------------------------- // Define the menu @@ -69,10 +80,6 @@ app.on('activate', () => { //------------------------------------------------------------------- // Auto updates //------------------------------------------------------------------- -var {autoUpdater} = require("electron-updater"); -let UPDATE_DOWNLOADED = false; -let update_window; - autoUpdater.on('checking-for-update', (ev) => { console.log('Checking for update...'); }) @@ -95,4 +102,4 @@ autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, autoUpdater.quitAndInstall(); }, 5000) }) -autoUpdater.checkForUpdates() +autoUpdater.checkForUpdates() \ No newline at end of file diff --git a/package.json b/package.json index 76a8c6d..2b3cd4a 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,12 @@ "main": "main.js", "description": "electron-updater example project", "author": "Matt Haggard", - "devDependencies": { + "dependencies": { "electron": "^1.4.15", - "electron-builder": "^12.3.1", + "electron-builder": "^12.3.1" + }, + "dependencies": { + "electron-log": "^1.3.0", "electron-updater": "^1.4.2" }, "build": { diff --git a/publish.sh b/publish.sh index 816067c..2ddd743 100755 --- a/publish.sh +++ b/publish.sh @@ -6,4 +6,5 @@ if [ -z "$GH_TOKEN" ]; then exit 1 fi +# This will build, package and upload the app to GitHub. build --win --mac -p always