diff --git a/src/module-cache.coffee b/src/module-cache.coffee index d6e981a5b..378cf900c 100644 --- a/src/module-cache.coffee +++ b/src/module-cache.coffee @@ -73,22 +73,6 @@ loadFolderCompatibility = (modulePath, rootPath, rootMetadata, moduleCache) -> undefined -exports.create = (modulePath) -> - metadataPath = path.join(modulePath, 'package.json') - metadata = JSON.parse(fs.readFileSync(metadataPath)) - - moduleCache = - version: 1 - dependencies: [] - folders: [] - - loadDependencies(modulePath, modulePath, metadata, moduleCache) - loadFolderCompatibility(modulePath, modulePath, metadata, moduleCache) - - metadata._atomModuleCache = moduleCache - fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2)) - undefined - satisfies = (version, rawRange) -> unless parsedRange = cache.ranges[rawRange] parsedRange = new semver.Range(rawRange) @@ -136,6 +120,22 @@ if debug global.requireTime += Date.now() - startTime exports +exports.create = (modulePath) -> + metadataPath = path.join(modulePath, 'package.json') + metadata = JSON.parse(fs.readFileSync(metadataPath)) + + moduleCache = + version: 1 + dependencies: [] + folders: [] + + loadDependencies(modulePath, modulePath, metadata, moduleCache) + loadFolderCompatibility(modulePath, modulePath, metadata, moduleCache) + + metadata._atomModuleCache = moduleCache + fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2)) + undefined + registered = false exports.register = -> return if registered diff --git a/src/package.coffee b/src/package.coffee index 91ea89175..1ec35b601 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -10,6 +10,7 @@ Q = require 'q' {deprecate} = require 'grim' $ = null # Defer require in case this is in the window-less browser process +ModuleCache = require './module-cache' ScopedProperties = require './scoped-properties' # Loads and activates a package's main module and resources such as @@ -47,6 +48,7 @@ class Package @emitter = new Emitter @metadata ?= Package.loadMetadata(@path) @name = @metadata?.name ? path.basename(@path) + ModuleCache.add(@path, @metadata) @reset() ###