Setup node path in Atom Window.

This lets windows run code from different resource paths.
This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-06-14 10:01:23 -07:00
parent 3ba7d68d4a
commit 2edb5b5496
3 changed files with 22 additions and 25 deletions

View File

@@ -46,7 +46,6 @@ class AtomApplication
@windows = []
@listenForArgumentsFromNewProcess()
@setupNodePath()
@setupJavaScriptArguments()
@buildApplicationMenu()
@handleEvents()
@@ -69,29 +68,6 @@ class AtomApplication
addWindow: (window) ->
@windows.push window
getHomeDir: ->
process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
setupNodePath: ->
resourcePaths = [
'src/stdlib'
'src/app'
'src/packages'
'src'
'vendor'
'static'
'node_modules'
'spec'
''
]
resourcePaths.push path.join(@getHomeDir(), '.atom', 'packages')
resourcePaths = resourcePaths.map (relativeOrAbsolutePath) =>
path.resolve @resourcePath, relativeOrAbsolutePath
process.env['NODE_PATH'] = resourcePaths.join path.delimiter
listenForArgumentsFromNewProcess: ->
fs.unlinkSync socketPath if fs.existsSync(socketPath)
server = net.createServer (connection) =>

View File

@@ -11,6 +11,7 @@ class AtomWindow
constructor: ({bootstrapScript, resourcePath, pathToOpen, exitWhenDone, @isSpec}) ->
global.atomApplication.addWindow(this)
@setupNodePath(resourcePath)
@browserWindow = new BrowserWindow show: false, title: 'Atom'
@handleEvents()
@@ -24,6 +25,26 @@ class AtomWindow
@openPath(pathToOpen)
setupNodePath: (resourcePath) ->
paths = [
'src/stdlib'
'src/app'
'src/packages'
'src'
'vendor'
'static'
'node_modules'
'spec'
''
]
paths.push path.join(global.homeDir, '.atom', 'packages')
paths = paths.map (relativeOrAbsolutePath) ->
path.resolve resourcePath, relativeOrAbsolutePath
process.env['NODE_PATH'] = paths.join path.delimiter
getInitialPath: ->
@browserWindow.loadSettings.initialPath

View File

@@ -7,7 +7,7 @@ $ = require 'jquery'
fsUtils = require 'fs-utils'
path = require 'path'
describe 'FuzzyFinder', ->
fdescribe 'FuzzyFinder', ->
[finderView] = []
beforeEach ->