From 944eb8b8b00b7ccebf3ab2c6443c64171f468c0d Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 6 Feb 2017 00:54:16 -0300 Subject: [PATCH] styling fixes; tests passing; added missing ms dependency. --- package.json | 1 + src/config.js | 3 +-- src/main/index.js | 6 +++--- src/main/menu.js | 2 +- src/plugins.js | 21 ++++++++------------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 242e4476..2512cc34 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.16.0", "mkdirp": "^0.5.1", + "ms": "^0.7.2", "musicmetadata": "^2.0.2", "network-address": "^1.1.0", "node-notifier": "^5.0.2", diff --git a/src/config.js b/src/config.js index aec53ff8..8751e54b 100644 --- a/src/config.js +++ b/src/config.js @@ -3,7 +3,6 @@ const fs = require('fs') const path = require('path') const electron = require('electron') const arch = require('arch') -const {resolve} = require('path') const gaze = require('gaze') const APP_NAME = 'WebTorrent' @@ -113,7 +112,7 @@ function updateConfig () { config = JSON.parse(fs.readFileSync(configFile)) } -function watch() { +function watch () { gaze(configFile, function (err) { if (err) { throw err diff --git a/src/main/index.js b/src/main/index.js index 0389ec72..c61aea87 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -78,7 +78,7 @@ function init () { // init new plugins then notify user plugins.subscribe(() => { - // update menu and windows + // update menu and windows // passing thru new plugin decorators initApp(state) }) @@ -106,8 +106,8 @@ function init () { // init and decorate window windows.main.init( - state, - {hidden: hidden}, + state, + {hidden: hidden}, (options) => plugins.decorateWindow(options) ) windows.webtorrent.init((options) => plugins.decorateWindow(options)) diff --git a/src/main/menu.js b/src/main/menu.js index b8a9cb9c..df400891 100644 --- a/src/main/menu.js +++ b/src/main/menu.js @@ -20,7 +20,7 @@ let menu = null function init (decorate) { let template = getMenuTemplate() if (decorate) template = decorate(template) - + menu = electron.Menu.buildFromTemplate(template) electron.Menu.setApplicationMenu(menu) } diff --git a/src/plugins.js b/src/plugins.js index 17864137..3a026283 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -3,6 +3,7 @@ const {resolve, basename} = require('path') const {writeFileSync} = require('fs') const State = require('./renderer/lib/state') const notifier = require('node-notifier') +const {app} = require('electron') const {sync: mkdirpSync} = require('mkdirp') const ms = require('ms') @@ -96,8 +97,8 @@ module.exports = class Plugins { } getId (plugins) { - const hash = crypto.createHash('sha256'); - hash.update(JSON.stringify(plugins)); + const hash = crypto.createHash('sha256') + hash.update(JSON.stringify(plugins)) return hash.digest('hex') } @@ -125,9 +126,7 @@ module.exports = class Plugins { return } - this.alert( - 'Error updating plugins: Check `${this.path}/npm-debug.log` for more information.' - ) + this.alert(`Error updating plugins: Check '${this.path}/npm-debug.log' for more information.`) return } @@ -269,13 +268,9 @@ module.exports = class Plugins { // Use the install command that is appropriate for our shell exec(installCommands[whichShell], { - cwd: this.path//, - // env, - // shell + cwd: this.path }, err => { - if (err) { - return fn(err) - } + if (err) return fn(err) fn(null) }) }).catch(fn) @@ -397,11 +392,11 @@ module.exports = class Plugins { * Logs passed arguments to console using a prefix. * */ -function log() { +function log () { const prefix = '[ PLUGINS ]-->' const args = [prefix] - for (var i=0; i