From e2e742b12eafa1314804b269c95a97ae979e8697 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 18 Jan 2016 15:50:30 -0800 Subject: [PATCH] Add build type to data directory path --- console/src/main.js | 47 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/console/src/main.js b/console/src/main.js index 1d2d407afe..9a3710e878 100644 --- a/console/src/main.js +++ b/console/src/main.js @@ -33,13 +33,52 @@ const osType = os.type(); const appIcon = path.join(__dirname, '../resources/console.png'); -function getRootHifiDataDirectory() { +function getBuildInfo() { + var buildInfoPath = null; + if (osType == 'Windows_NT') { - return path.resolve(osHomeDir(), 'AppData/Roaming/High Fidelity'); + buildInfoPath = path.resolve(process.execPath, 'build-info.json'); } else if (osType == 'Darwin') { - return path.resolve(osHomeDir(), 'Library/Application Support/High Fidelity'); + var contentPath = ".app/Contents/"; + var contentEndIndex = __dirname.indexOf(contentPath); + if (contentEndIndex != -1) { + // this is an app bundle + var appPath = __dirname.substring(0, contentEndIndex) + ".app"; + buildInfoPath = path.resolve(appPath, "/Contents/Resources/build-info.json"); + } + } + + const DEFAULT_BUILD_INFO = { releaseType: "", buildIdentifier: "dev" }; + var buildInfo = DEFAULT_BUILD_INFO; + + if (buildInfoPath) { + console.log('Build info path:', buildInfoPath); + try { + buildInfo = fs.readFileSync(buildInfoPath); + } catch (e) { + buildInfo = DEFAULT_BUILD_INFO; + } + } + + return buildInfo; +} + +const buildInfo = getBuildInfo(); + +console.log("build info", buildInfo); + + +function getRootHifiDataDirectory() { + var organization = "High Fidelity"; + if (buildInfo.releaseType != "PRODUCTION") { + organization += ' - ' + buildInfo.buildIdentifier; + } + if (osType == 'Windows_NT') { + return path.resolve(osHomeDir(), 'AppData/Roaming', organization); + } else if (osType == 'Darwin') { + return path.resolve(osHomeDir(), 'Library/Application Support', organization); } else { - return path.resolve(osHomeDir(), '.local/share/High Fidelity'); + return path.resolve(osHomeDir(), '.local/share/', organization); } }