move version number to build-utils

Summary:
* The generation of the version number is moved to build-utils so it can be used from the headless build process as well.
* The prelude script for the headless version exposes the version number on `global.__VERSION__`
* While at this file, moving some functions in the build process to use the Sync version. Doesn't matter for the build process anyways and the syntax is much nicer.

Reviewed By: passy

Differential Revision: D13843678

fbshipit-source-id: 7df8364044ab6ebc83a4060aab2e3a42ae48a934
This commit is contained in:
Daniel Büchele
2019-02-04 07:21:55 -08:00
committed by Facebook Github Bot
parent 5b68c59b5c
commit 22f9401e05
3 changed files with 28 additions and 45 deletions

View File

@@ -86,9 +86,19 @@ function buildFolder() {
}).catch(die);
}
function getVersionNumber() {
let {version} = require('../package.json');
const buildNumber = process.argv.join(' ').match(/--version=(\d+)/);
if (buildNumber && buildNumber.length > 0) {
version = [...version.split('.').slice(0, 2), buildNumber[1]].join('.');
}
return version;
}
module.exports = {
buildFolder,
compile,
die,
compileDefaultPlugins,
getVersionNumber,
};