Skip to content

Commit

Permalink
feat(check): printing error if trying to upgrade non-existent module, c…
Browse files Browse the repository at this point in the history
…loses #78
  • Loading branch information
bahmutov committed Dec 8, 2015
1 parent cd70bb6 commit ef43a5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ function getDependenciesToCheck(options, moduleNames) {
});
});
if (!options.tldr) {
console.log('only checking');
console.json(toCheck);
console.log('only checking modules');
console.log(toCheck.map(function (m) {
return m.name + '@' + m.version;
}));
}
}
return toCheck;
Expand Down
12 changes: 12 additions & 0 deletions src/next-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ function checkCurrentInstall(options) {

var isOnline = Q.denodeify(require('is-online'));

function makeSureValidModule(moduleNames, checkingModules) {
la(check.array(moduleNames), 'expected list of modules', moduleNames);
la(check.array(checkingModules), 'expected list of modules to check', checkingModules);
if (moduleNames.length === 1 && check.empty(checkingModules)) {
console.error('Could not find module "%s" in the list of dependencies', moduleNames[0]);
console.error('Please check the name');
process.exit(-1);
}
}

// returns promise
function checkAllUpdates(options) {
options = options || {};
Expand All @@ -101,6 +111,8 @@ function checkAllUpdates(options) {
var toCheck = getDependenciesToCheck(options, moduleName);
check.verify.array(toCheck, 'dependencies to check should be an array');

makeSureValidModule(moduleName, toCheck);

var testVersionsBound = testVersions.bind(null, {
modules: toCheck,
command: checkCommand,
Expand Down
1 change: 1 addition & 0 deletions test/e2e.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gt.module 'end 2 end tests',
teardown: ->
process.chdir __dirname

# TODO set the final version limit to check
gt.async '--module', ->
gt.exec 'node', [index, '--module', moduleName], 0
, ONE_MINUTE
Expand Down

0 comments on commit ef43a5b

Please sign in to comment.