build: allow getOutDir cli argument (#21545)

This commit is contained in:
Shelley Vohr 2019-12-17 14:00:42 -08:00 committed by GitHub
parent 54b4756a29
commit f0d52eaf0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 8 deletions

View file

@ -23,11 +23,23 @@ function getElectronExec () {
}
}
function getOutDir (shouldLog) {
if (process.env.ELECTRON_OUT_DIR) {
return process.env.ELECTRON_OUT_DIR
function getOutDir (options = {}) {
const shouldLog = options.shouldLog || false
if (options.outDir || process.env.ELECTRON_OUT_DIR) {
const outDir = options.outDir || process.env.ELECTRON_OUT_DIR
const outPath = path.resolve(SRC_DIR, 'out', outDir)
// Check that user-set variable is a valid/existing directory
if (fs.existsSync(outPath)) {
if (shouldLog) console.log(`OUT_DIR is: ${outDir}`)
return outDir
}
// Throw error if user passed/set nonexistent directory.
throw new Error(`${outDir} directory not configured on your machine.`)
} else {
for (const buildType of ['Testing', 'Release', 'Default']) {
for (const buildType of ['Testing', 'Release', 'Default', 'Debug']) {
const outPath = path.resolve(SRC_DIR, 'out', buildType)
if (fs.existsSync(outPath)) {
if (shouldLog) console.log(`OUT_DIR is: ${buildType}`)