diff --git a/script/lib/utils.js b/script/lib/utils.js index 2958c50e9b84..e3c7d483f009 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -4,13 +4,13 @@ const path = require('path') const ELECTRON_DIR = path.resolve(__dirname, '..', '..') const SRC_DIR = path.resolve(ELECTRON_DIR, '..') -const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug' require('colors') const pass = '\u2713'.green const fail = '\u2717'.red function getElectronExec () { + const OUT_DIR = getOutDir() switch (process.platform) { case 'darwin': return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron` @@ -23,6 +23,20 @@ function getElectronExec () { } } +function getOutDir (shouldLog) { + if (process.env.ELECTRON_OUT_DIR) { + return process.env.ELECTRON_OUT_DIR + } else { + for (const buildType of ['Debug', 'Testing', 'Release']) { + const outPath = path.resolve(SRC_DIR, 'out', buildType) + if (fs.existsSync(outPath)) { + if (shouldLog) console.log(`OUT_DIR is: ${buildType}`) + return buildType + } + } + } +} + function getAbsoluteElectronExec () { return path.resolve(SRC_DIR, getElectronExec()) } @@ -62,8 +76,8 @@ async function getCurrentBranch (gitDir) { module.exports = { getCurrentBranch, getElectronExec, + getOutDir, getAbsoluteElectronExec, ELECTRON_DIR, - OUT_DIR, SRC_DIR } diff --git a/script/nan-spec-runner.js b/script/nan-spec-runner.js index b5e40e288d3e..5230e4e00f37 100644 --- a/script/nan-spec-runner.js +++ b/script/nan-spec-runner.js @@ -14,7 +14,7 @@ if (!process.mainModule) { } async function main () { - const nodeDir = path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`) + const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(true)}/gen/node_headers`) const env = Object.assign({}, process.env, { npm_config_nodedir: nodeDir, npm_config_msvs_version: '2017', diff --git a/script/spec-runner.js b/script/spec-runner.js index abf54745152e..80e00adaf0b9 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -142,7 +142,7 @@ async function runMainProcessElectronTests () { } async function installSpecModules () { - const nodeDir = path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`) + const nodeDir = path.resolve(BASE, `out/${utils.getOutDir(true)}/gen/node_headers`) const env = Object.assign({}, process.env, { npm_config_nodedir: nodeDir, npm_config_msvs_version: '2017'