Skip to content

Commit

Permalink
fix(build): issues/29 version display (#43)
Browse files Browse the repository at this point in the history
* display version on creation
* integration test for version
  • Loading branch information
cdcabrera authored Apr 5, 2019
1 parent 6700a9b commit e48a322
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# main()
#
{
echo "Compiling version information..."
echo UI_VERSION="$(node -p 'require(`./package.json`).version').$(git rev-parse --short HEAD)" > ./.env.production.local
UI_VERSION="$(node -p 'require(`./package.json`).version').$(git rev-parse --short HEAD)"
echo "Compiling version information... v$UI_VERSION"
echo UI_VERSION="$UI_VERSION" > ./.env.production.local
}
10 changes: 10 additions & 0 deletions tests/version.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

describe('Version', () => {
const loadFile = file => (fs.existsSync(file) && fs.readFileSync(file, { encoding: 'utf-8' })) || '';

it('should have a specific version output', () => {
const fileContents = loadFile('./.env.production.local');
expect(/^UI_VERSION=\d\.\d\.\d\.[a-z0-9]{7}$/i.test(fileContents.trim())).toBe(true);
});
});

0 comments on commit e48a322

Please sign in to comment.