diff --git a/scripts/version.sh b/scripts/version.sh index 6deee317..241f48a1 100644 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -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 } diff --git a/tests/version.test.js b/tests/version.test.js new file mode 100644 index 00000000..173d20bf --- /dev/null +++ b/tests/version.test.js @@ -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); + }); +});