commit
19931397ac
2 changed files with 20 additions and 7 deletions
|
@ -6,14 +6,9 @@ const Menu = electron.Menu;
|
|||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const repl = require('repl');
|
||||
const url = require('url');
|
||||
|
||||
// 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();
|
||||
});
|
||||
|
||||
// Parse command line options.
|
||||
var argv = process.argv.slice(1);
|
||||
var option = { file: null, help: null, version: null, webdriver: null, modules: [] };
|
||||
|
@ -27,6 +22,8 @@ for (var i = 0; i < argv.length; i++) {
|
|||
} else if (argv[i] == '--help' || argv[i] == '-h') {
|
||||
option.help = true;
|
||||
break;
|
||||
} else if (argv[i] == '--interactive' || argv[i] == '-i') {
|
||||
option.interactive = true;
|
||||
} else if (argv[i] == '--test-type=webdriver') {
|
||||
option.webdriver = true;
|
||||
} else if (argv[i] == '--require' || argv[i] == '-r') {
|
||||
|
@ -40,6 +37,12 @@ for (var i = 0; i < argv.length; i++) {
|
|||
}
|
||||
}
|
||||
|
||||
// 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 && !option.interactive)
|
||||
app.quit();
|
||||
});
|
||||
|
||||
// Create default menu.
|
||||
app.once('ready', function() {
|
||||
if (Menu.getApplicationMenu())
|
||||
|
@ -275,6 +278,12 @@ function loadApplicationByUrl(appUrl) {
|
|||
require('./default_app').load(appUrl);
|
||||
}
|
||||
|
||||
function startRepl() {
|
||||
repl.start('> ').on('exit', function() {
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
// Start the specified app if there is one specified in command line, otherwise
|
||||
// start the default app.
|
||||
if (option.file && !option.webdriver) {
|
||||
|
@ -302,11 +311,14 @@ if (option.file && !option.webdriver) {
|
|||
helpMessage += " - .html/.htm file.\n";
|
||||
helpMessage += " - http://, https://, or file:// URL.\n";
|
||||
helpMessage += "\nOptions:\n";
|
||||
helpMessage += " -r, --require Module to preload (option can be repeated)\n";
|
||||
helpMessage += " -h, --help Print this usage message.\n";
|
||||
helpMessage += " -i, --interactive Open a REPL to the main process.\n";
|
||||
helpMessage += " -r, --require Module to preload (option can be repeated)\n";
|
||||
helpMessage += " -v, --version Print the version.";
|
||||
console.log(helpMessage);
|
||||
process.exit(0);
|
||||
} else if (option.interactive) {
|
||||
startRepl();
|
||||
} else {
|
||||
loadApplicationByUrl('file://' + __dirname + '/index.html');
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
"build": "python ./script/build.py -c D",
|
||||
"lint": "python ./script/eslint.py && python ./script/cpplint.py",
|
||||
"preinstall": "node -e 'process.exit(0)'",
|
||||
"repl": "python ./script/start.py --interactive",
|
||||
"start": "python ./script/start.py",
|
||||
"test": "python ./script/test.py"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue