From 495fa43753f30d067d0e6dbad5da78c6edc4818e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 8 Oct 2014 08:29:00 -0700 Subject: [PATCH] Allow passing in metadata to ModuleCache.add --- src/module-cache.coffee | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/module-cache.coffee b/src/module-cache.coffee index ce11c8c28..aef565917 100644 --- a/src/module-cache.coffee +++ b/src/module-cache.coffee @@ -34,6 +34,8 @@ loadDependencies = (modulePath, rootPath, rootMetadata, moduleCache) -> loadDependencies(childPath, rootPath, rootMetadata, moduleCache) + undefined + loadFolderCompatibility = (modulePath, rootPath, rootMetadata, moduleCache) -> metadataPath = path.join(modulePath, 'package.json') return unless fs.isFileSync(metadataPath) @@ -69,6 +71,8 @@ loadFolderCompatibility = (modulePath, rootPath, rootMetadata, moduleCache) -> loadFolderCompatibility(childPath, rootPath, rootMetadata, moduleCache) + undefined + exports.generateDependencies = (modulePath) -> metadataPath = path.join(modulePath, 'package.json') metadata = JSON.parse(fs.readFileSync(metadataPath)) @@ -83,6 +87,7 @@ exports.generateDependencies = (modulePath) -> metadata._atomModuleCache = moduleCache fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2)) + undefined satisfies = (version, rawRange) -> unless parsedRange = cache.ranges[rawRange] @@ -141,11 +146,14 @@ exports.register = -> resolvedPath ? originalResolveFilename(relativePath, parentModule) registered = true -exports.add = (directoryPath) -> - try - metadata = require(path.join(directoryPath, 'package.json')) - catch error - return + undefined + +exports.add = (directoryPath, metadata) -> + unless metadata? + try + metadata = require(path.join(directoryPath, 'package.json')) + catch error + return cacheToAdd = metadata?._atomModuleCache for dependency in cacheToAdd?.dependencies ? []