react/packages/react-devtools-extensions/utils.js
Brian Vaughn 5fc97420b9
Remove dependency on local git checkout from build process (#17475)
* Remove dependency on local git checkout from build process

* Updated Webpack dependencies to account for recent changes to deps for Flight
2019-11-27 07:48:09 -08:00

36 lines
765 B
JavaScript

const {execSync} = require('child_process');
const {readFileSync} = require('fs');
const {resolve} = require('path');
const GITHUB_URL = 'https://github.com/facebook/react';
function getGitCommit() {
try {
return execSync('git show -s --format=%h')
.toString()
.trim();
} catch (error) {
// Mozilla runs this command from a git archive.
// In that context, there is no Git revision.
return null;
}
}
function getVersionString() {
const packageVersion = JSON.parse(
readFileSync(
resolve(__dirname, '..', 'react-devtools-core', './package.json'),
),
).version;
const commit = getGitCommit();
return `${packageVersion}-${commit}`;
}
module.exports = {
GITHUB_URL,
getGitCommit,
getVersionString,
};