1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-24 04:39:01 +00:00

Add version to JS (#839)

* Add version to JS

* Throw if version wasn't found
This commit is contained in:
Andrey
2018-01-27 09:27:11 +02:00
committed by Paulus Schoutsen
parent c11a525a2d
commit 13f8fa7e11
3 changed files with 9 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
const fs = require('fs');
const gulp = require('gulp');
const rollupEach = require('gulp-rollup-each');
const commonjs = require('rollup-plugin-commonjs');
@@ -8,6 +9,11 @@ const uglify = require('../common/gulp-uglify.js');
const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');
const DEMO = !!JSON.parse(process.env.BUILD_DEMO || 'false');
const version = fs.readFileSync('setup.py', 'utf8').match(/\d{8}[^']*/);
if (!version) {
throw Error('Version not found');
}
const VERSION = version[0];
function getRollupInputOptions(es6) {
const babelOpts = {
@@ -51,6 +57,7 @@ function getRollupInputOptions(es6) {
__DEV__: JSON.stringify(DEV),
__DEMO__: JSON.stringify(DEMO),
__BUILD__: JSON.stringify(es6 ? 'latest' : 'es5'),
__VERSION__: JSON.stringify(VERSION),
},
}),
],