Files
bower/lib/commands/update.js
André Cruz 7becb19da4 Implement check of newer versions in the list command.
Also:
- Fix some errors not being emitted when a command failed.
- Update semver module; no need to check .valid against null.
2013-07-03 14:37:28 +01:00

51 lines
1.2 KiB
JavaScript

var EventEmitter = require('events').EventEmitter;
var mout = require('mout');
var Project = require('../core/Project');
var Logger = require('../core/Logger');
var cli = require('../util/cli');
var defaultConfig = require('../config');
function update(names, options, config) {
var project;
var emitter = new EventEmitter();
var logger = new Logger();
options = options || {};
config = mout.object.deepMixIn(config || {}, defaultConfig);
project = new Project(config, logger);
// If names is an empty array, null them
if (names && !names.length) {
names = null;
}
project.update(names, options)
.then(function (installed) {
emitter.emit('end', installed);
})
.fail(function (error) {
emitter.emit('error', error);
});
return logger.pipe(emitter);
}
// -------------------
update.line = function (argv) {
var options = update.options(argv);
return update(options.argv.remain.slice(1), options);
};
update.options = function (argv) {
return cli.readOptions({
'production': { type: Boolean, shorthand: 'p' }
}, argv);
};
update.completion = function () {
// TODO:
};
module.exports = update;