mirror of
https://github.com/atom/atom.git
synced 2026-01-20 20:38:09 -05:00
🐎 Resolve uncached core dependencies
Trust modules under the resource path to be there without stat-ing and verifying.
This commit is contained in:
committed by
Kevin Sawicki
parent
7926531330
commit
171411823f
@@ -16,6 +16,7 @@ cache =
|
||||
folders: {}
|
||||
ranges: {}
|
||||
registered: false
|
||||
resourcePath: null
|
||||
|
||||
loadDependencies = (modulePath, rootPath, rootMetadata, moduleCache) ->
|
||||
for childPath in fs.listSync(path.join(modulePath, 'node_modules'))
|
||||
@@ -99,8 +100,8 @@ getCachedModulePath = (relativePath, parentModule) ->
|
||||
return unless candidates?
|
||||
|
||||
for version, resolvedPath of candidates
|
||||
if Module._cache.hasOwnProperty(resolvedPath) and satisfies(version, range)
|
||||
return resolvedPath
|
||||
if Module._cache.hasOwnProperty(resolvedPath) or resolvedPath.indexOf(cache.resourcePath) is 0
|
||||
return resolvedPath if satisfies(version, range)
|
||||
|
||||
undefined
|
||||
|
||||
@@ -138,14 +139,16 @@ exports.create = (modulePath) ->
|
||||
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2))
|
||||
undefined
|
||||
|
||||
exports.register = ->
|
||||
exports.register = (resourcePath) ->
|
||||
return if cache.registered
|
||||
|
||||
originalResolveFilename = Module._resolveFilename
|
||||
Module._resolveFilename = (relativePath, parentModule) ->
|
||||
resolvedPath = getCachedModulePath(relativePath, parentModule)
|
||||
resolvedPath ? originalResolveFilename(relativePath, parentModule)
|
||||
|
||||
cache.registered = true
|
||||
cache.resourcePath = resourcePath
|
||||
|
||||
undefined
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ window.onload = function() {
|
||||
require('../src/coffee-cache').register();
|
||||
|
||||
ModuleCache = require('../src/module-cache');
|
||||
ModuleCache.register(loadSettings.resourcePath);
|
||||
ModuleCache.add(loadSettings.resourcePath);
|
||||
ModuleCache.register();
|
||||
|
||||
require(loadSettings.bootstrapScript);
|
||||
ipc.sendChannel('window-command', 'window:loaded')
|
||||
|
||||
Reference in New Issue
Block a user