fix(dev-mode): Don’t save to config.json, use flag instead

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.
This commit is contained in:
Ben Gotow 2016-09-30 14:37:03 -07:00
parent 08128e3dc6
commit 4eeb808976
3 changed files with 12 additions and 16 deletions

View file

@ -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.
#

View file

@ -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') {

View file

@ -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)) {