From 4eeb8089769cfc188fd82ccfb7e907005c2f7262 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 30 Sep 2016 14:37:03 -0700 Subject: [PATCH] =?UTF-8?q?fix(dev-mode):=20Don=E2=80=99t=20save=20to=20co?= =?UTF-8?q?nfig.json,=20use=20flag=20instead?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out even the built, packaged version of the app can be restarted into dev mode by adding `—dev` to argv and using the new relaunch API. --- src/browser/application-menu.coffee | 2 -- src/browser/application.es6 | 19 +++++++++++-------- src/browser/window-launcher.es6 | 7 +------ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/browser/application-menu.coffee b/src/browser/application-menu.coffee index 13fa40589..22e515fcf 100644 --- a/src/browser/application-menu.coffee +++ b/src/browser/application-menu.coffee @@ -13,8 +13,6 @@ class ApplicationMenu @setActiveTemplate(@getDefaultTemplate()) global.application.autoUpdateManager.on 'state-changed', (state) => @updateAutoupdateMenuItem(state) - global.application.config.observe 'devMode', (state) => - @updateDevModeItem() # Public: Updates the entire menu with the given keybindings. # diff --git a/src/browser/application.es6 b/src/browser/application.es6 index 9fa398479..7b5ed3e5d 100644 --- a/src/browser/application.es6 +++ b/src/browser/application.es6 @@ -319,17 +319,20 @@ export default class Application extends EventEmitter { }); this.on('application:install-update', () => { - this.quitting = true - this.windowManager.cleanupBeforeAppQuit() - this.autoUpdateManager.install() + this.quitting = true; + this.windowManager.cleanupBeforeAppQuit(); + this.autoUpdateManager.install(); }); this.on('application:toggle-dev', () => { - this.devMode = !this.devMode; - this.config.set('devMode', this.devMode ? true : undefined); - this.windowManager.destroyAllWindows(); - this.windowManager.devMode = this.devMode; - this.openWindowsForTokenState(); + let args = process.argv.slice(1); + if (args.includes('--dev')) { + args = args.filter(a => a !== '--dev'); + } else { + args.push('--dev') + } + app.relaunch({args}); + app.quit(); }); if (process.platform === 'darwin') { diff --git a/src/browser/window-launcher.es6 b/src/browser/window-launcher.es6 index ddbfd7a46..ccb43d868 100644 --- a/src/browser/window-launcher.es6 +++ b/src/browser/window-launcher.es6 @@ -36,12 +36,7 @@ export default class WindowLauncher { } newWindow(options) { - // Normally, you enter dev mode by passing the --dev command line flag. - // But for developers using the compiled app, it's easier to toggle dev - // mode from the menu and have it persist through relaunch. - const devOpt = this.config.get('devMode') ? {devMode: true} : {}; - - const opts = Object.assign({}, this.defaultWindowOpts, devOpt, options); + const opts = Object.assign({}, this.defaultWindowOpts, options); let win; if (this._mustUseColdWindow(opts)) {