Skip to content

Commit 42229da

Browse files
committed
Remove commander from deps
1 parent d6d48b6 commit 42229da

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

bin/git-hooks

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
#!/usr/bin/env node
22

3-
var program = require('commander');
43
var cli = require('../lib/cli');
5-
6-
program
7-
.version(require('../package.json').version)
8-
.usage('[options]')
9-
.description('A tool to manage project Git hooks')
10-
.option('--install', 'Replace existing hooks in this repository with a call git-hooks. Move old hooks directory to hooks.old')
11-
.option('--uninstall', 'Remove existing hooks in this repository and rename hooks.old back to hooks')
12-
.parse(process.argv);
13-
14-
cli(program);
4+
cli(process.argv[2]);

lib/cli.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,43 @@
11
var gitHooks = require('../lib/git-hooks');
2+
var options = {
3+
help: 'Output usage information',
4+
version: 'Output the version number',
5+
install: 'Replace existing hooks in this repository with a call git-hooks. Move old hooks directory to hooks.old',
6+
uninstall: 'Remove existing hooks in this repository and rename hooks.old back to hooks'
7+
};
28

3-
module.exports = function (program) {
4-
var command = program.install && 'install' || program.uninstall && 'uninstall';
5-
6-
if (!gitHooks[command]) {
7-
return program.outputHelp();
8-
}
9+
module.exports = function (command) {
10+
command = command && command.replace(/-/g, '');
911

10-
try {
11-
gitHooks[command]();
12-
} catch (e) {
13-
console.error(e.message);
12+
switch (command) {
13+
case 'version':
14+
console.log(require('../package.json').version);
15+
break;
16+
case 'install':
17+
case 'uninstall':
18+
try {
19+
gitHooks[command]();
20+
} catch (e) {
21+
console.error(e.message);
22+
}
23+
break;
24+
default:
25+
outputHelp();
1426
}
1527
};
28+
29+
/**
30+
* Outputs the help to console.
31+
*/
32+
function outputHelp() {
33+
console.log(
34+
'\nUsage: git-hooks [options]\n\n' +
35+
'A tool to manage project Git hooks\n\n' +
36+
'Options:\n\n' +
37+
Object.keys(options)
38+
.map(function (key) {
39+
return ' --' + key + '\t' + options[key] + '\n';
40+
})
41+
.join('')
42+
);
43+
}

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"examples",
1919
"lib"
2020
],
21-
"dependencies": {
22-
"commander": "^2.8.1"
23-
},
2421
"devDependencies": {
2522
"chai": "^2.3.0",
2623
"jscs": "^1.13.1",

0 commit comments

Comments
 (0)