Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit 97cc22f

Browse files
committed
Add some new command line options to pass to bower install and npm install commands
1 parent db9b13f commit 97cc22f

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

lib/coa.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

33
var PATH = require('path'),
4-
Q = require('q');
4+
Q = require('q'),
5+
C = require('cli-color');
56

67
module.exports = require('coa').Cmd()
78
.name(PATH.basename(process.argv[1]))
@@ -17,11 +18,35 @@ module.exports = require('coa').Cmd()
1718
return p.name + ' ' + p.version;
1819
})
1920
.end()
21+
.opt()
22+
.name('npm-development')
23+
.title('Pass ' + C.yellow('--development') + ' option to ' + C.blueBright('npm install') + ' (' + C.yellow('--production') + ' is passed by default)')
24+
.long('npm-development')
25+
.flag()
26+
.end()
27+
.opt()
28+
.name('bower-production')
29+
.title('Pass ' + C.yellow('--production') + ' option to ' + C.blueBright('bower install') + ' (' + C.yellow('--development') + ' is passed by default)')
30+
.long('bower-production')
31+
.flag()
32+
.end()
33+
.opt()
34+
.name('force')
35+
.title('Pass ' + C.yellow('--force') + ' option to ' + C.blueBright('bower install'))
36+
.long('force')
37+
.flag()
38+
.end()
39+
.opt()
40+
.name('force-latest')
41+
.title('Pass ' + C.yellow('--force-latest') + ' option to ' + C.blueBright('bower install'))
42+
.long('force-latest')
43+
.flag()
44+
.end()
2045
.completable()
21-
.act(function() {
46+
.act(function(opts) {
2247
var defer = Q.defer();
2348

24-
require('./install')()
49+
require('./install')(null, opts)
2550
.on('error', defer.reject.bind(defer))
2651
.on('data', function(data) {
2752
process.stdout.write(data);

lib/install.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ var PATH = require('path'),
44
CP = require('child_process'),
55
B = require('bower'),
66
Q = require('q'),
7+
L = require('lodash'),
78
QFS = require('q-io/fs'),
89
Emitter = require('events').EventEmitter;
910

1011
module.exports = function(paths, options) {
11-
options = options || {};
12+
options = L.extend({}, options || {});
13+
options.production = !!options['bower-production'];
1214

1315
var emitter = new Emitter();
1416

@@ -28,7 +30,7 @@ module.exports = function(paths, options) {
2830
return packages[key];
2931
}),
3032
npmBin = process.env.NPM || 'npm',
31-
npmArgs = ['install', '--production'],
33+
npmArgs = ['install', options['npm-development'] ? '--development' : '--production'],
3234
promise = Q.resolve();
3335

3436
emitter.emit('paths', paths);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"dependencies": {
2020
"q": "~0.9.6",
2121
"coa": "~0.4.0",
22-
"q-io": "~1.9.1"
22+
"q-io": "~1.9.1",
23+
"lodash": "~1.3.1",
24+
"cli-color": "~0.2.2"
2325
},
2426
"peerDependencies": {
2527
"bower": "~0.10.0"

0 commit comments

Comments
 (0)