Skip to content

Commit 8b48882

Browse files
committed
fix(cli): cli displays the corrent version number
1 parent d5c1b38 commit 8b48882

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/cli/cli.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,29 @@
33
*/
44
var fs = require('fs'),
55
path = require('path'),
6-
json = JSON.parse(fs.readFileSync('package.json', 'utf8')),
7-
version = json.version,
86
Command = require('commander').Command,
97
program = new Command(),
108
path1 = path.resolve(__dirname + '/../dist/showdown.js'),
119
path2 = path.resolve(__dirname + '/../../.build/showdown.js'),
12-
showdown;
10+
showdown,
11+
version;
1312

1413
// require shodown. We use conditional loading for each use case
1514
if (fs.existsSync(path1)) {
1615
// production. File lives in bin directory
1716
showdown = require(path1);
17+
version = require(path.resolve(__dirname + '/../package.json')).version;
1818
} else if (fs.existsSync(path2)) {
1919
// testing envo, uses the concatenated stuff for testing
2020
showdown = require(path2);
21+
version = require(path.resolve(__dirname + '/../../package.json')).version;
2122
} else {
2223
// cold testing (manual) of cli.js in the src file. We load the dist file
2324
showdown = require('../../dist/showdown');
25+
version = require('../../package.json');
2426
}
2527

28+
2629
program
2730
.name('showdown')
2831
.description('CLI to Showdownjs markdown parser v' + version)

0 commit comments

Comments
 (0)