Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect dependency versions for components #280

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
};
};