2018-09-13 20:46:49 +00:00
|
|
|
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
|
2018-09-13 16:57:39 +00:00
|
|
|
|
2018-12-03 21:28:10 +00:00
|
|
|
const { GitProcess } = require('dugite')
|
2018-09-13 16:57:39 +00:00
|
|
|
const path = require('path')
|
|
|
|
|
2018-12-03 21:28:10 +00:00
|
|
|
require('colors')
|
|
|
|
const pass = '\u2713'.green
|
|
|
|
const fail = '\u2717'.red
|
|
|
|
|
2018-09-13 16:57:39 +00:00
|
|
|
function getElectronExec () {
|
|
|
|
switch (process.platform) {
|
|
|
|
case 'darwin':
|
|
|
|
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
|
|
|
|
case 'win32':
|
|
|
|
return `out/${OUT_DIR}/electron.exe`
|
|
|
|
case 'linux':
|
|
|
|
return `out/${OUT_DIR}/electron`
|
|
|
|
default:
|
|
|
|
throw new Error('Unknown platform')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAbsoluteElectronExec () {
|
|
|
|
return path.resolve(__dirname, '../../..', getElectronExec())
|
|
|
|
}
|
|
|
|
|
2018-12-03 21:28:10 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:57:39 +00:00
|
|
|
module.exports = {
|
2018-12-03 21:28:10 +00:00
|
|
|
getCurrentBranch,
|
2018-09-13 16:57:39 +00:00
|
|
|
getElectronExec,
|
|
|
|
getAbsoluteElectronExec,
|
|
|
|
OUT_DIR
|
|
|
|
}
|