File tree 2 files changed +7
-8
lines changed
2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ var clone = require('clone');
12
12
var fs = require ( 'fs' ) ;
13
13
var studio = require ( './Studio.js' ) ;
14
14
var os = require ( 'os' ) ;
15
+ var PKG_VERSION = require ( '../package.json' ) . version ;
15
16
16
17
function Botkit ( configuration ) {
17
18
var botkit = {
@@ -1190,14 +1191,7 @@ function Botkit(configuration) {
1190
1191
botkit . version = function ( ) {
1191
1192
1192
1193
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 ;
1201
1195
}
1202
1196
return botkit . my_version ;
1203
1197
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ describe('Test', function() {
23
23
24
24
describe ( 'Botkit' , function ( ) {
25
25
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
+ } ) ;
26
31
27
32
it ( 'should start and then stop' , function ( done ) {
28
33
var controller = Botkit . slackbot ( { debug : false } ) ;
You can’t perform that action at this time.
0 commit comments