Make detect order of resourcePath more robust.

1. Use the resource-path of process.argv if specified;
2. Otherwise if --dev is specified then use ~/github/atom;
3. If no valid resourcePath is provide use the ones in bundle.
This commit is contained in:
Cheng Zhao
2013-05-23 10:36:27 +08:00
parent b5bd7160d2
commit 1d9449838f

View File

@@ -1,3 +1,4 @@
fs = require 'fs'
path = require 'path'
optimist = require 'optimist'
delegate = require 'atom_delegate'
@@ -7,9 +8,6 @@ executedFrom = null
pathsToOpen = null
atomApplication = null
require('fs').writeFileSync('/Users/corey/Desktop/moo.txt', process.cwd())
getHomeDir = ->
process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
@@ -38,7 +36,16 @@ parseCommandLine = ->
executedFrom = args['executed-from']
devMode = args['dev']
pathsToOpen = args._
resourcePath = if devMode then path.join(getHomeDir(), 'github/atom') else path.dirname(__dirname)
if args['resource-path']
resourcePath = args['resource-path']
else if devMode
resourcePath = path.join(getHomeDir(), 'github/atom')
try
fs.statSync resourcePath
catch e
resourcePath = path.dirname(__dirname)
bootstrapApplication = ->
parseCommandLine()