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,16 +108,29 @@ module.exports.get_gradle_wrapper = function() {
} else { ++i; } } else { ++i; }
} }
} else if (module.exports.isWindows()) { } else if (module.exports.isWindows()) {
var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
if (fs.existsSync(androidPath)) { var result = child_process.spawnSync(path.join(__dirname,'getASPath.bat'));
program_dir = fs.readdirSync(androidPath); //console.log('result.stdout =' + result.stdout.toString());
while (i < program_dir.length && !foundStudio) { //console.log('result.stderr =' + result.stderr.toString());
if (program_dir[i].startsWith('Android Studio')) {
foundStudio = true; if(result.stderr.toString().length > 0) {
androidStudioPath = path.join(process.env['ProgramFiles'], 'Android', program_dir[i], 'gradle'); var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
} else { ++i; } if (fs.existsSync(androidPath)) {
program_dir = fs.readdirSync(androidPath);
while (i < program_dir.length && !foundStudio) {
if (program_dir[i].startsWith('Android Studio')) {
foundStudio = true;
androidStudioPath = path.join(process.env['ProgramFiles'], 'Android', program_dir[i], 'gradle');
} else { ++i; }
}
} }
} }
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)) { if (androidStudioPath !== null && fs.existsSync(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%