Skip to content

Commit 3cc9188

Browse files
committed
Print CLI and GitBook versions on --version
1 parent ba5f264 commit 3cc9188

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

bin/gitbook.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,27 @@ function runPromise(p) {
2727
});
2828
}
2929

30+
function printGitbookVersion(v) {
31+
var actualVersion = (v.name != v.version)? ' ('+v.version+')' : '';
32+
return v.name + actualVersion;
33+
}
3034

3135
// Init gitbook-cli
3236
manager.init();
3337

3438
program
35-
.version(pkg.version)
3639
.option('-v, --gitbook [version]', 'specify GitBook version to use')
37-
.option('-d, --debug', 'enable verbose error');
38-
40+
.option('-d, --debug', 'enable verbose error')
41+
.option('-V, --version', 'Display running versions of gitbook and gitbook-cli', function() {
42+
console.log('CLI version:', pkg.version);
43+
runPromise(
44+
manager.ensure(bookRoot, program.gitbook)
45+
.then(function(v) {
46+
console.log('GitBook version:', printGitbookVersion(v));
47+
process.exit(0);
48+
})
49+
);
50+
});
3951

4052
program
4153
.command('ls')
@@ -69,7 +81,7 @@ program
6981
runPromise(
7082
manager.ensure(bookRoot, program.gitbook)
7183
.then(function(v) {
72-
console.log('GitBook version is', v.name, (v.name != v.version? '('+v.version+')' : ''));
84+
console.log('GitBook version is', printGitbookVersion(v));
7385
})
7486
);
7587
});

0 commit comments

Comments
 (0)