From 68b3ab4225cfa37ecd907819304dea4ff5c48c44 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Wed, 28 Sep 2016 14:51:48 -0400 Subject: [PATCH] fix(spec): remove unnecessary messages & prevent extra hot window --- spec_integration/jasmine/bootstrap.js | 4 ---- src/browser/application.es6 | 1 + src/browser/auto-update-manager.es6 | 1 + src/browser/main.js | 5 +++++ src/browser/window-launcher.es6 | 3 ++- src/browser/window-manager.es6 | 4 ++-- static/index.js | 8 +++++++- 7 files changed, 18 insertions(+), 8 deletions(-) diff --git a/spec_integration/jasmine/bootstrap.js b/spec_integration/jasmine/bootstrap.js index cf2c27f53..6db216d2a 100644 --- a/spec_integration/jasmine/bootstrap.js +++ b/spec_integration/jasmine/bootstrap.js @@ -16,10 +16,6 @@ console.errorColor = function(err){ } } -console.inspect = function(val) { - console.log(util.inspect(val, true, depth=7, colorize=true)); -} - jasmine.NYLAS_ROOT_PATH = process.argv[3].split("NYLAS_ROOT_PATH=")[1] jasmine.UNIT_TEST_TIMEOUT = 120*1000; jasmine.BOOT_TIMEOUT = 30*1000; diff --git a/src/browser/application.es6 b/src/browser/application.es6 index 52e5356fa..9fa398479 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -61,6 +61,7 @@ export default class Application extends EventEmitter { configDirPath: this.configDirPath, config: this.config, devMode: this.devMode, + specMode: this.specMode, safeMode: this.safeMode, initializeInBackground: initializeInBackground, }); diff --git a/src/browser/auto-update-manager.es6 b/src/browser/auto-update-manager.es6 index 7ed06b130..a7d752dac 100644 --- a/src/browser/auto-update-manager.es6 +++ b/src/browser/auto-update-manager.es6 @@ -89,6 +89,7 @@ export default class AutoUpdateManager extends EventEmitter { } autoUpdater.on('error', (event, message) => { + if (this.specMode) return false; console.error(`Error Downloading Update: ${message}`); this.setState(ErrorState); }); diff --git a/src/browser/main.js b/src/browser/main.js index b7f1637ca..0155a9343 100644 --- a/src/browser/main.js +++ b/src/browser/main.js @@ -1,6 +1,11 @@ /* eslint dot-notation: 0 */ /* eslint global-require: 0 */ global.shellStartTime = Date.now(); +var util = require('util') + +console.inspect = function consoleInspect(val) { + console.log(util.inspect(val, true, depth=7, colorize=true)); +} const app = require('electron').app; const path = require('path'); diff --git a/src/browser/window-launcher.es6 b/src/browser/window-launcher.es6 index ca3bcf441..ddbfd7a46 100644 --- a/src/browser/window-launcher.es6 +++ b/src/browser/window-launcher.es6 @@ -16,7 +16,7 @@ let winNum = 0; export default class WindowLauncher { static EMPTY_WINDOW = "emptyWindow" - constructor({devMode, safeMode, resourcePath, configDirPath, onCreatedHotWindow, config}) { + constructor({devMode, safeMode, specMode, resourcePath, configDirPath, onCreatedHotWindow, config}) { this.defaultWindowOpts = { frame: process.platform !== "darwin", hidden: false, @@ -31,6 +31,7 @@ export default class WindowLauncher { } this.config = config; this.onCreatedHotWindow = onCreatedHotWindow; + if (specMode) return; this.createHotWindow(); } diff --git a/src/browser/window-manager.es6 b/src/browser/window-manager.es6 index b425b9afc..dd4017110 100644 --- a/src/browser/window-manager.es6 +++ b/src/browser/window-manager.es6 @@ -9,7 +9,7 @@ const ONBOARDING_WINDOW = "onboarding" export default class WindowManager { - constructor({devMode, safeMode, resourcePath, configDirPath, initializeInBackground, config}) { + constructor({devMode, safeMode, specMode, resourcePath, configDirPath, initializeInBackground, config}) { this.initializeInBackground = initializeInBackground; this._windows = {}; @@ -17,7 +17,7 @@ export default class WindowManager { this._registerWindow(win); this._didCreateNewWindow(win); } - this.windowLauncher = new WindowLauncher({devMode, safeMode, resourcePath, configDirPath, config, onCreatedHotWindow}); + this.windowLauncher = new WindowLauncher({devMode, safeMode, specMode, resourcePath, configDirPath, config, onCreatedHotWindow}); } get(windowKey) { diff --git a/static/index.js b/static/index.js index 06b1ee852..969fcae67 100644 --- a/static/index.js +++ b/static/index.js @@ -2,13 +2,19 @@ window.eval = global.eval = function() { throw new Error("Sorry, N1 does not support window.eval() for security reasons."); } +var util = require('util') var path = require('path'); var electron = require('electron'); var remote = electron.remote; +console.inspect = function consoleInspect(val) { + console.log(util.inspect(val, true, depth=7, colorize=true)); +} + function setLoadTime (loadTime) { if (global.NylasEnv) { - global.NylasEnv.loadTime = loadTime + global.NylasEnv.loadTime = loadTime; + if (NylasEnv.inSpecMode()) return; console.log('Window load time: ' + global.NylasEnv.getWindowLoadTime() + 'ms') } }