mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
chore(NA): do not use execa on bazel workspace status update script (#93532)
This commit is contained in:
parent
40a3386553
commit
2a8e4b260f
1 changed files with 17 additions and 13 deletions
|
@ -17,13 +17,21 @@
|
|||
// If the script exits with non-zero code, it's considered as a failure
|
||||
// and the output will be discarded.
|
||||
|
||||
(async () => {
|
||||
const execa = require('execa');
|
||||
(() => {
|
||||
const cp = require('child_process');
|
||||
const os = require('os');
|
||||
|
||||
async function runCmd(cmd, args) {
|
||||
function runCmd(cmd, args) {
|
||||
try {
|
||||
return await execa(cmd, args);
|
||||
const spawnResult = cp.spawnSync(cmd, args);
|
||||
const exitCode = spawnResult.status !== null ? spawnResult.status : 1;
|
||||
const stdoutStr = spawnResult.stdout.toString();
|
||||
const stdout = stdoutStr ? stdoutStr.trim() : null;
|
||||
|
||||
return {
|
||||
exitCode,
|
||||
stdout,
|
||||
};
|
||||
} catch (e) {
|
||||
return { exitCode: 1 };
|
||||
}
|
||||
|
@ -31,29 +39,25 @@
|
|||
|
||||
// Git repo
|
||||
const kbnGitOriginName = process.env.KBN_GIT_ORIGIN_NAME || 'origin';
|
||||
const repoUrlCmdResult = await runCmd('git', [
|
||||
'config',
|
||||
'--get',
|
||||
`remote.${kbnGitOriginName}.url`,
|
||||
]);
|
||||
const repoUrlCmdResult = runCmd('git', ['config', '--get', `remote.${kbnGitOriginName}.url`]);
|
||||
if (repoUrlCmdResult.exitCode === 0) {
|
||||
// Only output REPO_URL when found it
|
||||
console.log(`REPO_URL ${repoUrlCmdResult.stdout}`);
|
||||
}
|
||||
|
||||
// Commit SHA
|
||||
const commitSHACmdResult = await runCmd('git', ['rev-parse', 'HEAD']);
|
||||
const commitSHACmdResult = runCmd('git', ['rev-parse', 'HEAD']);
|
||||
if (commitSHACmdResult.exitCode === 0) {
|
||||
console.log(`COMMIT_SHA ${commitSHACmdResult.stdout}`);
|
||||
|
||||
// Branch
|
||||
const gitBranchCmdResult = await runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
|
||||
const gitBranchCmdResult = runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
|
||||
if (gitBranchCmdResult.exitCode === 0) {
|
||||
console.log(`GIT_BRANCH ${gitBranchCmdResult.stdout}`);
|
||||
}
|
||||
|
||||
// Tree status
|
||||
const treeStatusCmdResult = await runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
|
||||
const treeStatusCmdResult = runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
|
||||
const treeStatusVarStr = 'GIT_TREE_STATUS';
|
||||
if (treeStatusCmdResult.exitCode === 0) {
|
||||
console.log(`${treeStatusVarStr} Clean`);
|
||||
|
@ -64,7 +68,7 @@
|
|||
|
||||
// Host
|
||||
if (process.env.CI) {
|
||||
const hostCmdResult = await runCmd('hostname');
|
||||
const hostCmdResult = runCmd('hostname');
|
||||
const hostStr = hostCmdResult.stdout.split('-').slice(0, -1).join('-');
|
||||
const coresStr = os.cpus().filter((cpu, index) => {
|
||||
return !cpu.model.includes('Intel') || index % 2 === 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue