mirror of
https://github.com/bower/bower.git
synced 2026-01-15 01:08:07 -05:00
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.
41 lines
978 B
JavaScript
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;
|