mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
Initial take on the commands + renderers + cli.
This commit is contained in:
17
lib/commands/help.js
Normal file
17
lib/commands/help.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var Emitter = require('events').EventEmitter;
|
||||
|
||||
function help(name) {
|
||||
var emitter = new Emitter();
|
||||
|
||||
// TODO
|
||||
return emitter;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
|
||||
module.exports = help;
|
||||
|
||||
module.exports.line = function (argv) {
|
||||
// TODO
|
||||
return help();
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
module.exports = {
|
||||
|
||||
};
|
||||
'help': require('./help'),
|
||||
'install': require('./install')
|
||||
};
|
||||
|
||||
50
lib/commands/install.js
Normal file
50
lib/commands/install.js
Normal file
@@ -0,0 +1,50 @@
|
||||
var Emitter = require('events').EventEmitter;
|
||||
var Project = require('../core/Project');
|
||||
var cli = require('../util/cli');
|
||||
var help = require('./help');
|
||||
|
||||
function install(endpoints, options) {
|
||||
var project;
|
||||
var emitter = new Emitter();
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Sanitize endpoints
|
||||
if (endpoints && !endpoints.length) {
|
||||
endpoints = null;
|
||||
}
|
||||
|
||||
project = new Project(options);
|
||||
project.install(endpoints)
|
||||
.then(function (installed) {
|
||||
emitter.emit('end', installed);
|
||||
}, function (error) {
|
||||
emitter.emit('error', error);
|
||||
}, function (notification) {
|
||||
emitter.emit('data', notification);
|
||||
});
|
||||
|
||||
return emitter;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
|
||||
module.exports = install;
|
||||
|
||||
module.exports.line = function (argv) {
|
||||
var options = module.exports.options(argv);
|
||||
|
||||
return options.help ?
|
||||
help('install') :
|
||||
install(options.argv.remain.slice(1), options);
|
||||
};
|
||||
|
||||
module.exports.options = function (argv) {
|
||||
return cli.readOptions(argv, {
|
||||
'save': { type: Boolean, shorthand: 'S' },
|
||||
'save-dev': { type: Boolean, shorthand: 'D' },
|
||||
'force': { type: Boolean, shorthand: 'f' },
|
||||
'offline': { type: Boolean, shorthand: 'o' },
|
||||
'production': { type: Boolean, shorthand: 'p' }
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user