forked from bower/bower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bower
executable file
·40 lines (31 loc) · 1.21 KB
/
bower
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
var semver = require('semver');
var nopt = require('nopt');
var path = require('path');
var pkg = require(path.join(__dirname, '..', 'package.json'));
var template = require('../lib/util/template');
var bower = require('../lib');
var command;
var options;
var shorthand;
var input = process.argv;
var cmdList = Object.keys(bower.commands);
var nodeVer = process.version;
var reqVer = pkg.engines.node;
process.title = 'bower';
if (reqVer && !semver.satisfies(nodeVer, reqVer)) {
throw new Error('Required: node ' + reqVer);
}
shorthand = { 'v': ['--version'] };
options = { version: Boolean };
options = nopt(options, shorthand, process.argv);
bower.version = pkg.version;
if (options.version) return console.log(bower.version);
if (~cmdList.indexOf(command = options.argv.remain && options.argv.remain.shift())) bower.command = command;
bower.commands[bower.command || 'help'].line(input)
.on('data', function (data) { data && console.log(data); })
.on('end', function (data) { data && console.log(data); })
.on('error', function (err) {
if (options.verbose) throw err;
else template('error', { message: err.message }).on('data', function (d) { console.log (d); });
});