Skip to content

Commit

Permalink
Respect dependency versions for components (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
opoku authored and matteofigus committed Aug 30, 2016
1 parent 7cc9250 commit 177a5eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/cli/domain/get-components-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
9 changes: 7 additions & 2 deletions src/cli/domain/get-missing-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]){
Expand All @@ -22,4 +27,4 @@ module.exports = function(dependencies, components){
});

return missing;
};
};
11 changes: 8 additions & 3 deletions src/registry/domain/dependencies-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand All @@ -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;
Expand All @@ -33,4 +38,4 @@ module.exports = function(options){
});

return depObj;
};
};

0 comments on commit 177a5eb

Please sign in to comment.