mirror of
https://github.com/atom/atom.git
synced 2026-02-15 00:55:14 -05:00
💉 dependencies into AtomPackage
Removes use of resourcePath and config globals
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user