Skip to content

Commit

Permalink
Merge pull request #21 from yusinto/master
Browse files Browse the repository at this point in the history
Added 'undefined' check on VERSION otherwise unbundled usage from npm fails
  • Loading branch information
apucacao authored Sep 9, 2016
2 parents 8c79644 + c1e1f69 commit 71181f6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
15 changes: 8 additions & 7 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,25 @@
},
"devDependencies": {
"chai": "3.5.0",
"gzip-size": "3.0.0",
"in-publish": "2.0.0",
"karma": "0.13.22",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1",
"karma-mocha": "1.0.1",
"karma-mocha-reporter": "2.0.4",
"karma-chrome-launcher": "1.0.1",
"karma-phantomjs-launcher": "0.2.1",
"karma-phantomjs-shim": "1.1.2",
"karma-sinon": "1.0.5",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "1.7.0",
"karma-sinon": "1.0.5",
"mocha": "2.5.3",
"phantomjs": "1.9.18",
"sinon": "1.17.4",
"webpack": "1.13.1",
"gzip-size": "3.0.0",
"in-publish": "2.0.0",
"pretty-bytes": "3.0.1",
"readline-sync": "1.4.4"
"readline-sync": "1.4.4",
"semver-compare": "^1.0.0",
"sinon": "1.17.4",
"webpack": "1.13.1"
},
"dependencies": {
"Base64": "1.0.0",
Expand Down
13 changes: 13 additions & 0 deletions src/__tests__/LDClient-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var LDClient = require('../index');
var semverCompare = require('semver-compare');

describe('LDClient', function() {
var xhr;
Expand Down Expand Up @@ -45,6 +46,18 @@ describe('LDClient', function() {
var settingsRequest = requests[0];
expect(/sdk\/eval/.test(settingsRequest.url)).to.be.false;
});

it('should contain package version', function () {
// Arrange
var version = LDClient.version;

// Act: all client bundles above 1.0.7 should contain package version
// https://github.com/substack/semver-compare
var result = semverCompare(version, '1.0.6');

// Assert
expect(result).to.equal(1);
});
});

});
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ function initialize(env, user, options) {
}

module.exports = {
initialize: initialize,
version: VERSION
initialize: initialize
};

if(typeof VERSION !== 'undefined') {
module.exports.version = VERSION;
}

0 comments on commit 71181f6

Please sign in to comment.