Files
react/packages/react-devtools-extensions/utils.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.0 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
2019-08-13 17:58:03 -07:00
const {execSync} = require('child_process');
const {readFileSync} = require('fs');
const {resolve} = require('path');
2019-04-11 18:44:44 -07:00
const GITHUB_URL = 'https://github.com/facebook/react';
function getGitCommit() {
try {
return execSync('git show -s --no-show-signature --format=%h')
.toString()
.trim();
} catch (error) {
// Mozilla runs this command from a git archive.
// In that context, there is no Git revision.
return null;
2019-05-23 11:55:32 -07:00
}
2019-04-11 18:44:44 -07:00
}
function getVersionString(packageVersion = null) {
if (packageVersion == null) {
packageVersion = JSON.parse(
readFileSync(
resolve(__dirname, '..', 'react-devtools-core', './package.json'),
),
).version;
}
2019-04-11 18:44:44 -07:00
const commit = getGitCommit();
2019-04-11 18:44:44 -07:00
return `${packageVersion}-${commit}`;
}
module.exports = {
GITHUB_URL,
getGitCommit,
getVersionString,
};