Skip to content

Commit fe41821

Browse files
author
Ben Brown
authored
Merge pull request howdyai#775 from monte-hayward/master
howdyai#774 expose package version to bundle
2 parents 381f0d7 + 626bf74 commit fe41821

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/CoreBot.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var clone = require('clone');
1212
var fs = require('fs');
1313
var studio = require('./Studio.js');
1414
var os = require('os');
15+
var PKG_VERSION = require('../package.json').version;
1516

1617
function Botkit(configuration) {
1718
var botkit = {
@@ -1190,14 +1191,7 @@ function Botkit(configuration) {
11901191
botkit.version = function() {
11911192

11921193
if (!botkit.my_version) {
1193-
var pkg = fs.readFileSync(__dirname + '/../package.json');
1194-
try {
1195-
pkg = JSON.parse(pkg);
1196-
} catch (err) {
1197-
throw new Error('Could not determine Botkit version', err);
1198-
}
1199-
1200-
botkit.my_version = pkg.version;
1194+
botkit.my_version = PKG_VERSION;
12011195
}
12021196
return botkit.my_version;
12031197

tests/Slack_web_api.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ describe('Test', function() {
2323

2424
describe('Botkit', function() {
2525
this.timeout(5000);
26+
it('should return a package version number', function(done){
27+
var controller = Botkit.slackbot({debug: false});
28+
should.exist(controller.version());
29+
done();
30+
});
2631

2732
it('should start and then stop', function(done) {
2833
var controller = Botkit.slackbot({debug: false});

0 commit comments

Comments
 (0)