2013-09-09 02:54:08 +00:00
|
|
|
var app = require('app');
|
2014-05-05 08:35:06 +00:00
|
|
|
var dialog = require('dialog');
|
2013-07-17 08:21:33 +00:00
|
|
|
var path = require('path');
|
2013-10-21 08:48:52 +00:00
|
|
|
var optimist = require('optimist');
|
2013-04-17 12:05:43 +00:00
|
|
|
|
2013-09-09 02:54:08 +00:00
|
|
|
// 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();
|
|
|
|
});
|
|
|
|
|
2014-01-31 08:40:20 +00:00
|
|
|
var argv = optimist(process.argv.slice(1)).boolean('ci').argv;
|
2013-10-03 03:36:17 +00:00
|
|
|
|
2013-07-17 08:21:33 +00:00
|
|
|
// Start the specified app if there is one specified in command line, otherwise
|
|
|
|
// start the default app.
|
|
|
|
if (argv._.length > 0) {
|
2013-07-24 07:20:59 +00:00
|
|
|
try {
|
|
|
|
require(path.resolve(argv._[0]));
|
|
|
|
} catch(e) {
|
2014-05-05 08:50:11 +00:00
|
|
|
app.focus();
|
|
|
|
dialog.showMessageBox({
|
|
|
|
type: 'warning',
|
|
|
|
buttons: ['OK'],
|
|
|
|
title: 'Error opening app',
|
|
|
|
message: 'The app provided is not a valid atom-shell app, please read the docs on how to write one:',
|
|
|
|
detail: 'https://github.com/atom/atom-shell/tree/master/docs'
|
|
|
|
});
|
|
|
|
process.exit(1);
|
2013-07-24 07:20:59 +00:00
|
|
|
}
|
2013-10-03 03:36:17 +00:00
|
|
|
} else if (argv.version) {
|
2013-10-03 03:48:13 +00:00
|
|
|
console.log('v' + process.versions['atom-shell']);
|
2013-10-03 03:36:17 +00:00
|
|
|
process.exit(0);
|
2013-07-17 08:21:33 +00:00
|
|
|
} else {
|
|
|
|
require('./default_app.js');
|
2013-04-15 07:39:54 +00:00
|
|
|
}
|