Fix revision bundling

Summary:
This fixes headless not terminating due to the `package.json` not being readable.
I instead write this to the `global` object in the same way that the version is
set.

Reviewed By: jknoxville

Differential Revision: D14579316

fbshipit-source-id: 238afe912366c423552305e120088f4abac4c20b
This commit is contained in:
Pascal Hartig
2019-03-22 10:35:30 -07:00
committed by Facebook Github Bot
parent 57a24769e8
commit 939cc531e2
5 changed files with 26 additions and 14 deletions

View File

@@ -10,6 +10,7 @@ const compilePlugins = require('../static/compilePlugins');
const tmp = require('tmp');
const path = require('path');
const fs = require('fs-extra');
const cp = require('child-process-es6-promise');
function die(err) {
console.error(err.stack);
@@ -98,10 +99,19 @@ function getVersionNumber() {
return version;
}
// Asynchronously determine current mercurial revision as string or `null` in case of any error.
function genMercurialRevision() {
return cp
.spawn('hg', ['log', '-r', '.', '-T', '{node}'])
.catch(err => null)
.then(res => (res && res.stdout) || null);
}
module.exports = {
buildFolder,
compile,
die,
compileDefaultPlugins,
getVersionNumber,
genMercurialRevision,
};