chore: move getCurrentBranch to a util file (#15921)
* chore: move getCurrentBranch to a util file * fix import
This commit is contained in:
parent
a1a431eb87
commit
d3c58ea48c
4 changed files with 30 additions and 53 deletions
|
@ -1,7 +1,12 @@
|
|||
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
|
||||
|
||||
const { GitProcess } = require('dugite')
|
||||
const path = require('path')
|
||||
|
||||
require('colors')
|
||||
const pass = '\u2713'.green
|
||||
const fail = '\u2717'.red
|
||||
|
||||
function getElectronExec () {
|
||||
switch (process.platform) {
|
||||
case 'darwin':
|
||||
|
@ -19,7 +24,22 @@ function getAbsoluteElectronExec () {
|
|||
return path.resolve(__dirname, '../../..', getElectronExec())
|
||||
}
|
||||
|
||||
async function getCurrentBranch (gitDir) {
|
||||
const gitArgs = ['rev-parse', '--abbrev-ref', 'HEAD']
|
||||
const branchDetails = await GitProcess.exec(gitArgs, gitDir)
|
||||
if (branchDetails.exitCode === 0) {
|
||||
const currentBranch = branchDetails.stdout.trim()
|
||||
console.log(`${pass} current git branch is: ${currentBranch}`)
|
||||
return currentBranch
|
||||
} else {
|
||||
const error = GitProcess.parseError(branchDetails.stderr)
|
||||
console.log(`${fail} couldn't get details current branch: `, error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCurrentBranch,
|
||||
getElectronExec,
|
||||
getAbsoluteElectronExec,
|
||||
OUT_DIR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue