From 3c0671c179a2ce5502c607f0a1f068a104c579af Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 9 Sep 2013 10:54:08 +0800 Subject: [PATCH] Quit when all windows are closed if running an app by passing it in command line. --- browser/default_app/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/browser/default_app/main.js b/browser/default_app/main.js index 862b59d58fec..4ca183fd5868 100644 --- a/browser/default_app/main.js +++ b/browser/default_app/main.js @@ -1,7 +1,14 @@ +var app = require('app'); var argv = require('optimist').argv; var dialog = require('dialog'); var path = require('path'); +// Quit when all windows are closed and no other one is listening to this. +app.on('window-all-closed', function() { + if (app.listeners('window-all-closed').length == 1) + app.quit(); +}); + // Start the specified app if there is one specified in command line, otherwise // start the default app. if (argv._.length > 0) {