Extract the version extract from webpack config (#5798)

This commit is contained in:
Paulus Schoutsen
2020-05-07 10:26:02 -07:00
committed by GitHub
parent b69d5e0fa3
commit b6309cfd16
2 changed files with 16 additions and 11 deletions

View File

@@ -1,3 +1,7 @@
const fs = require("fs");
const path = require("path");
const paths = require("./paths.js");
module.exports = {
isProdBuild() {
return process.env.NODE_ENV === "production";
@@ -11,4 +15,13 @@ module.exports = {
isNetlify() {
return process.env.NETLIFY === "true";
},
version() {
const version = fs
.readFileSync(path.resolve(paths.polymer_dir, "setup.py"), "utf8")
.match(/\d{8}\.\d+/);
if (!version) {
throw Error("Version not found");
}
return version[0];
},
};