From 8c8887c3472d99c50047764529e44a2f467abb00 Mon Sep 17 00:00:00 2001 From: Osei Poku Date: Sun, 14 Aug 2016 11:46:42 -0700 Subject: [PATCH] Respect dependency versions for components --- src/cli/domain/get-components-deps.js | 4 ++-- src/cli/domain/get-missing-deps.js | 9 +++++++-- src/registry/domain/dependencies-resolver.js | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/cli/domain/get-components-deps.js b/src/cli/domain/get-components-deps.js index c0ef10f36..736d9c389 100644 --- a/src/cli/domain/get-components-deps.js +++ b/src/cli/domain/get-components-deps.js @@ -10,10 +10,10 @@ module.exports = function(components){ var pkg = fs.readJsonSync(path.join(c, 'package.json')); _.forEach(_.keys(pkg.dependencies), function(d){ if(!_.contains(deps, d)){ - deps.push(d); + deps.push(d + '@' + pkg.dependencies[d]); } }); }); return deps; -}; \ No newline at end of file +}; diff --git a/src/cli/domain/get-missing-deps.js b/src/cli/domain/get-missing-deps.js index 0126a771c..a06f02639 100644 --- a/src/cli/domain/get-missing-deps.js +++ b/src/cli/domain/get-missing-deps.js @@ -8,7 +8,12 @@ module.exports = function(dependencies, components){ var missing = []; _.forEach(dependencies, function(npmModule){ - var pathToModule = path.resolve('node_modules/', npmModule); + var index = npmModule.indexOf('@'), + moduleName = npmModule; + if (index > 0) { + moduleName = npmModule.substr(0, index); + } + var pathToModule = path.resolve('node_modules/', moduleName); try { if(!!require.cache[pathToModule]){ @@ -22,4 +27,4 @@ module.exports = function(dependencies, components){ }); return missing; -}; \ No newline at end of file +}; diff --git a/src/registry/domain/dependencies-resolver.js b/src/registry/domain/dependencies-resolver.js index 8b885fc8a..29b1bc04c 100644 --- a/src/registry/domain/dependencies-resolver.js +++ b/src/registry/domain/dependencies-resolver.js @@ -14,8 +14,13 @@ module.exports = function(options){ logger.log(strings.messages.registry.RESOLVING_DEPENDENCIES.yellow); _.forEach(options.dependencies, function(dependency){ + var dependencyName = dependency, + ix = dependency.indexOf('@'); + if (ix > 0) { + dependencyName = dependency.substr(0, ix); + } var dependenciesBasePath = path.resolve('.', 'node_modules'), - dependencyPath = path.resolve(dependenciesBasePath, dependency), + dependencyPath = path.resolve(dependenciesBasePath, dependencyName), packagePath = path.resolve(dependencyPath, 'package.json'); if(!fs.existsSync(packagePath)){ @@ -24,7 +29,7 @@ module.exports = function(options){ } else { try { depObj[dependency] = require(dependencyPath); - logger.log('├── '.green + dependency + '@' + fs.readJsonSync(packagePath).version); + logger.log('├── '.green + dependencyName + '@' + fs.readJsonSync(packagePath).version); } catch(e){ logger.log((dependency + ' => ').yellow + strings.errors.registry.GENERIC_ERROR.red); throw e; @@ -33,4 +38,4 @@ module.exports = function(options){ }); return depObj; -}; \ No newline at end of file +};