Skip to content

Commit

Permalink
Merge pull request #562 from OpenGeoscience/publish-git-sha
Browse files Browse the repository at this point in the history
Include git SHA in the built bundle
  • Loading branch information
jbeezley committed May 10, 2016
2 parents 6dcb286 + 85fa552 commit 1db67be
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 121 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
119 changes: 0 additions & 119 deletions sources.json

This file was deleted.

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,}$/);
});
});
16 changes: 15 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
var path = require('path');
var webpack = require('webpack');
var exec = require('child_process').execSync;
var sha = '';

if (!exec) {
console.warn('Node 0.12 or greater is required for detecting the git hash.');
}

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 1db67be

Please sign in to comment.