Skip to content

Commit

Permalink
Add git sha to the built bundle.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeezley committed May 9, 2016
1 parent 445558b commit 7e7d792
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
src/vgl/**
src/version.js
src/sha.js
src/util/wigglemaps.js
src/util/distanceGrid.js
geo.js
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = $.extend({
vectorFeature: require('./vectorFeature'),
inherit: require('./inherit'),
version: require('./version'),
sha: require('./sha'),

util: require('./util'),
d3: require('./d3'),
Expand Down
1 change: 1 addition & 0 deletions src/sha.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = GEO_SHA;
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = VERSION;
module.exports = GEO_VERSION;
7 changes: 7 additions & 0 deletions tests/cases/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ describe('geo.version', function () {
expect(geo.version).toMatch(/[0-9]+\.[0-9]+\.[0-9]+[_a-zA-Z]*/);
});
});

describe('geo.version', function () {
var geo = require('../test-utils').geo;
it('Git SHA is defined', function () {
expect(geo.sha).toMatch(/^[0-9a-f]{8,}$/);
});
});
12 changes: 11 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
var path = require('path');
var webpack = require('webpack');
var exec = require('child_process').execSync;
var sha = '';

try {
sha = exec('git rev-parse HEAD', {cwd: __dirname}).toString().trim();
} catch (e) {
console.warn('Could not determine git hash.');
}

var define_plugin = new webpack.DefinePlugin({
VERSION: JSON.stringify(require('./package.json').version)
GEO_SHA: JSON.stringify(sha),
GEO_VERSION: JSON.stringify(require('./package.json').version)
});

module.exports = {
Expand Down

0 comments on commit 7e7d792

Please sign in to comment.