CB-12605 In Windows get Android studio path from the registry

This closes #387
This commit is contained in:
Jesse MacFadyen 2017-06-20 16:54:32 -07:00 committed by Joe Bowser
parent 3a6e898b12
commit 5cc14b8031
2 changed files with 24 additions and 8 deletions

View File

@ -108,6 +108,12 @@ module.exports.get_gradle_wrapper = function() {
} else { ++i; }
}
} else if (module.exports.isWindows()) {
var result = child_process.spawnSync(path.join(__dirname,'getASPath.bat'));
//console.log('result.stdout =' + result.stdout.toString());
//console.log('result.stderr =' + result.stderr.toString());
if(result.stderr.toString().length > 0) {
var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
if (fs.existsSync(androidPath)) {
program_dir = fs.readdirSync(androidPath);
@ -119,6 +125,13 @@ module.exports.get_gradle_wrapper = function() {
}
}
}
else {
// console.log('got android studio path from registry');
// remove the (os independent) new line char at the end of stdout
// add gradle to match the above.
androidStudioPath = path.join(result.stdout.toString().split('\r\n')[0],'gradle');
}
}
if (androidStudioPath !== null && fs.existsSync(androidStudioPath)) {
var dirs = fs.readdirSync(androidStudioPath);

View File

@ -0,0 +1,3 @@
@ECHO OFF
for /f "tokens=2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Android Studio" /v Path') do set "ASPath=%%~b"
ECHO %ASPath%