Files
bower/lib/commands/update.js
Thomas Scholtes 5c83972401 Use promise interface for commands
This commit changes the interface of the command functions exported by the
files in `lib/commands`. The functions now return a promise and accept a logger
as the first argument. This has several advantages

* The promise style is consistent with the rest of the code.
* It removes a lot of duplicate code.
* The command factory does not need to proxy the logger object.
2014-06-20 21:14:26 +02:00

41 lines
978 B
JavaScript

var mout = require('mout');
var Project = require('../core/Project');
var cli = require('../util/cli');
var defaultConfig = require('../config');
function update(logger, names, options, config) {
var project;
options = options || {};
config = mout.object.deepFillIn(config || {}, defaultConfig);
project = new Project(config, logger);
// If names is an empty array, null them
if (names && !names.length) {
names = null;
}
return project.update(names, options);
}
// -------------------
update.line = function (logger, argv) {
var options = update.options(argv);
var names = options.argv.remain.slice(1);
return update(logger, names, options);
};
update.options = function (argv) {
return cli.readOptions({
'force-latest': { type: Boolean, shorthand: 'F' },
'production': { type: Boolean, shorthand: 'p' }
}, argv);
};
update.completion = function () {
// TODO:
};
module.exports = update;