Skip to content

Commit cd45a19

Browse files
committed
Merge branch 'command-abbreviations' of git://github.com/alFReD-NSH/bower
2 parents a0bb847 + b5c363b commit cd45a19

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

bin/bower

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ options = nopt(options, shorthand, process.argv);
3030
bower.version = pkg.version;
3131

3232
if (options.version) return console.log(bower.version);
33-
if (~cmdList.indexOf(command = options.argv.remain && options.argv.remain.shift())) bower.command = command;
33+
34+
command = options.argv.remain && options.argv.remain.shift();
35+
command = bower.abbreviations[command];
36+
37+
if (command) bower.command = command;
3438

3539

3640
// Temporarory fix for #22 #320 #187

lib/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
// http://opensource.org/licenses/MIT
77
// ==========================================
88

9+
var abbrev = require('abbrev');
10+
var commands = require('./commands');
11+
912
module.exports = {
10-
commands: require('./commands'),
13+
commands: commands,
14+
abbreviations: abbrev(Object.keys(commands)),
1115
config: require('./core/config')
1216
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"rc": "~0.0.6",
3434
"unzip": "0.1.4",
3535
"tar": "~0.1.13",
36-
"promptly": "~0.1.0"
36+
"promptly": "~0.1.0",
37+
"abbrev": "~1.0.4"
3738
},
3839
"scripts": {
3940
"test": "mocha --reporter spec --timeout 40000"

test/abbreviations.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*jshint plusplus:false*/
2+
3+
var bower = require('../lib');
4+
var assert = require('assert');
5+
6+
var commandsList = Object.keys(bower.commands);
7+
var abbreviations = bower.abbreviations;
8+
9+
describe('abbreviations', function () {
10+
it('Should contain all commands in full', function () {
11+
commandsList.forEach(function (command) {
12+
assert(abbreviations[command]);
13+
});
14+
});
15+
it('Should contain abbreviations that are not ambiguous', function () {
16+
assert.equal(abbreviations.s, 'search');
17+
assert.equal(abbreviations.ins, 'install');
18+
assert.equal(abbreviations.inst, 'install');
19+
assert.equal(abbreviations.cache, 'cache-clean');
20+
assert.equal(abbreviations.compl, 'completion');
21+
});
22+
});

0 commit comments

Comments
 (0)