-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.js
More file actions
53 lines (47 loc) · 1.45 KB
/
index.js
File metadata and controls
53 lines (47 loc) · 1.45 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
var program = require('commander');
var NpmStrategy = require('./lib/npm/strategy');
var BowerStrategy = require('./lib/bower/strategy');
program
.usage('[options] [packageName ...]')
.option('-i, install', 'Install packages')
.option('-P, --production', 'Install/Pack production packages')
.option('-s, --strategy [type]', 'Uses specified strategy [npm|bower] to install/pack packages. Default is "npm"', 'npm')
.option('-v, --verbose', 'Logs out verbose log messages');
program.on('--help', function() {
console.log(' Examples:');
console.log('');
console.log(' $ pac -P install');
console.log(' $ pac grunt');
console.log(' $ pac -s bower install');
console.log(' $ pac -s bower angular');
console.log('');
});
program.parse(process.argv);
// Determine which strategy to use
var strategy;
if (program.strategy === 'bower') {
strategy = new BowerStrategy({
mode: program.production ? 'production' : 'develop',
verbose: program.verbose ? true : false
});
} else if (program.strategy === 'npm') {
strategy = new NpmStrategy({
mode: program.production ? 'production' : 'develop',
verbose: program.verbose ? true : false
});
} else {
console.error('Specified strategy is not supported');
process.exit(1);
}
if (program.install) {
strategy.install();
} else {
if (program.args >= 1) {
program.args.forEach(function(module) {
strategy.pack(module);
});
} else {
strategy.pack();
}
}