Add pre-resolved path to require('atom')

This commit is contained in:
Kevin Sawicki
2014-10-09 09:50:53 -07:00
parent f495db41e7
commit 41598af2b2
2 changed files with 10 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ nativeModules = process.binding('natives')
cache =
debug: false
atomExportsPath: null
dependencies: {}
extensions: {}
folders: {}
@@ -101,6 +102,8 @@ resolveFilePath = (relativePath, parentModule) ->
return
resolveModulePath = (relativePath, parentModule) ->
return cache.atomExportsPath if relativePath is 'atom'
return unless relativePath
return unless parentModule?.id
@@ -170,7 +173,7 @@ exports.create = (modulePath) ->
return
exports.register = (resourcePath) ->
exports.register = ({resourcePath, devMode}={}) ->
return if cache.registered
originalResolveFilename = Module._resolveFilename
@@ -182,6 +185,11 @@ exports.register = (resourcePath) ->
cache.registered = true
cache.resourcePath = resourcePath
if devMode
cache.atomExportsPath = path.join(resourcePath, 'exports', 'atom.coffee')
else
cache.atomExportsPath = path.join(resourcePath, 'exports', 'atom.js')
return
exports.add = (directoryPath, metadata) ->

View File

@@ -18,7 +18,7 @@ window.onload = function() {
require('../src/coffee-cache').register();
ModuleCache = require('../src/module-cache');
ModuleCache.register(loadSettings.resourcePath);
ModuleCache.register(loadSettings);
ModuleCache.add(loadSettings.resourcePath);
require(loadSettings.bootstrapScript);