]> khamidou — GitHub mirrors - electron.git/commitdiff
Don't use third party dependency in default_app.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 25 Aug 2014 11:11:26 +0000 (19:11 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 26 Aug 2014 01:50:45 +0000 (09:50 +0800)
atom/browser/default_app/main.js
atom/browser/default_app/package.json
script/bootstrap.py

index c988a4cae9b25b7965c90b8694d4e91d8888d3b7..922dd799e3800176deb96357a02081d1a8091ed6 100644 (file)
@@ -2,7 +2,6 @@ var app = require('app');
 var dialog = require('dialog');
 var fs = require('fs');
 var path = require('path');
-var optimist = require('optimist');
 
 // Quit when all windows are closed and no other one is listening to this.
 app.on('window-all-closed', function() {
@@ -10,14 +9,27 @@ app.on('window-all-closed', function() {
     app.quit();
 });
 
-var argv = optimist(process.argv.slice(1)).boolean('ci').argv;
+// Parse command line options.
+var argv = process.argv.slice(1);
+var option = { file: null, version: null };
+for (var i in argv) {
+  if (argv[i] == '--version' || argv[i] == '-v') {
+    option.version = true;
+    break;
+  } else if (argv[i][0] == '-') {
+    continue;
+  } else {
+    option.file = argv[i];
+    break;
+  }
+}
 
 // Start the specified app if there is one specified in command line, otherwise
 // start the default app.
-if (argv._.length > 0) {
+if (option.file) {
   try {
     // Override app name and version.
-    var packagePath = path.resolve(argv._[0]);
+    var packagePath = path.resolve(option.file);
     var packageJsonPath = path.join(packagePath, 'package.json');
     if (fs.existsSync(packageJsonPath)) {
       var packageJson = JSON.parse(fs.readFileSync(packageJsonPath));
@@ -48,7 +60,7 @@ if (argv._.length > 0) {
       throw e;
     }
   }
-} else if (argv.version) {
+} else if (option.version) {
   console.log('v' + process.versions['atom-shell']);
   process.exit(0);
 } else {
index 1995b130953835bb9a9f12f7ba31bff2141304ba..be1749b577818abae06d9465e9fa9c98b6479dd2 100644 (file)
@@ -2,8 +2,5 @@
   "name": "atom-shell-default-app",
   "productName": "Atom Shell Default App",
   "version": "0.1.0",
-  "main": "main.js",
-  "dependencies": {
-    "optimist": "*"
-  }
+  "main": "main.js"
 }
index 443a4767f8157eaa15fe3fbfe83530a2d05ac951..5ce068bfab959784f2839062cc2ddd5873e2a3ef 100755 (executable)
@@ -22,7 +22,6 @@ def main():
     enable_verbose_execute()
   update_submodules()
   update_node_modules('.')
-  update_atom_modules('atom/browser/default_app')
   update_atom_modules('spec')
   bootstrap_brightray(args.url)
   if sys.platform == 'cygwin':