💉 dependencies into AtomPackage

Removes use of resourcePath and config globals
This commit is contained in:
Kevin Sawicki
2013-10-07 14:38:19 -07:00
parent 722be2267d
commit 87bfcf5683
2 changed files with 19 additions and 13 deletions

View File

@@ -8,7 +8,11 @@ module.exports =
class PackageManager
_.extend @prototype, EventEmitter
constructor: ->
constructor: ({configDirPath, devMode, @resourcePath}) ->
@packageDirPaths = [path.join(configDirPath, "packages")]
if devMode
@packageDirPaths.unshift(path.join(configDirPath, "dev", "packages"))
@loadedPackages = {}
@activePackages = {}
@packageStates = {}
@@ -83,10 +87,10 @@ class PackageManager
resolvePackagePath: (name) ->
return name if fsUtils.isDirectorySync(name)
packagePath = fsUtils.resolve(config.packageDirPaths..., name)
packagePath = fsUtils.resolve(@packageDirPaths..., name)
return packagePath if fsUtils.isDirectorySync(packagePath)
packagePath = path.join(window.resourcePath, 'node_modules', name)
packagePath = path.join(@resourcePath, 'node_modules', name)
return packagePath if @isInternalPackage(packagePath)
isInternalPackage: (packagePath) ->
@@ -108,11 +112,11 @@ class PackageManager
getAvailablePackagePaths: ->
packagePaths = []
for packageDirPath in config.packageDirPaths
for packageDirPath in @packageDirPaths
for packagePath in fsUtils.listSync(packageDirPath)
packagePaths.push(packagePath) if fsUtils.isDirectorySync(packagePath)
for packagePath in fsUtils.listSync(path.join(window.resourcePath, 'node_modules'))
for packagePath in fsUtils.listSync(path.join(@resourcePath, 'node_modules'))
packagePaths.push(packagePath) if @isInternalPackage(packagePath)
_.uniq(packagePaths)