Skip to content

Commit

Permalink
feat(deps): running npm update and prune before running the command, c…
Browse files Browse the repository at this point in the history
…loses #75
  • Loading branch information
bahmutov committed Dec 8, 2015
1 parent 8cdeaf2 commit 26bfb92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"is-online": "5.0.0",
"lazy-ass": "1.1.0",
"lodash": "3.10.1",
"npm-utils": "0.4.0",
"npm-utils": "1.0.0",
"optimist": "0.6.1",
"q": "2.0.3",
"quote": "0.4.0",
Expand Down
15 changes: 11 additions & 4 deletions src/next-update.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
var la = require('lazy-ass');
var check = require('check-more-types');
var verify = check.verify;
require('console.json');

var log = require('debug')('next-update');
var Q = require('q');
Q.longStackSupport = true;
var check = require('check-types');
var verify = check.verify;
var depsOk = require('deps-ok');
var _ = require('lodash');

Expand All @@ -17,6 +16,7 @@ var testVersions = require('./test-module-version').testModulesVersions;
var runTest = require('./test-module-version').testPromise;
var getDependenciesToCheck = require('./dependencies');
var reportAvailable = require('./report-available');
var npmUtils = require('npm-utils');

var boundConsoleLog = console.log.bind(console);

Expand Down Expand Up @@ -46,19 +46,26 @@ function checkDependenciesInstalled() {
if (depsOk(process.cwd())) {
defer.resolve();
} else {
var msg = 'Current installation is not complete. Please run `npm install` or `bower install` first';
var msg = 'Current installation is incomplete. Please run `npm install` or `bower install` first';
defer.reject(new Error(msg));
}
});
return defer.promise;
}

function cleanDependencies() {
var update = _.partial(npmUtils.test, 'npm update');
var prune = _.partial(npmUtils.test, 'npm prune');
return update().then(prune);
}

function checkCurrentInstall(options) {
options = options || {};
var log = options.tldr ? _.noop : boundConsoleLog;
log('checking if the current state works');

return checkDependenciesInstalled()
return cleanDependencies()
.then(checkDependenciesInstalled)
.then(function () {
return runTest(options, options.testCommand)();
})
Expand Down

0 comments on commit 26bfb92

Please sign in to comment.