mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-31 09:02:50 +08:00
CB-12605 In Windows get Android studio path from the registry
This closes #387
This commit is contained in:
parent
3a6e898b12
commit
5cc14b8031
29
bin/templates/cordova/lib/check_reqs.js
vendored
29
bin/templates/cordova/lib/check_reqs.js
vendored
@ -108,16 +108,29 @@ module.exports.get_gradle_wrapper = function() {
|
||||
} else { ++i; }
|
||||
}
|
||||
} else if (module.exports.isWindows()) {
|
||||
var androidPath = path.join(process.env['ProgramFiles'], 'Android') + '/';
|
||||
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; }
|
||||
|
||||
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);
|
||||
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)) {
|
||||
|
3
bin/templates/cordova/lib/getASPath.bat
Normal file
3
bin/templates/cordova/lib/getASPath.bat
Normal 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%
|
Loading…
Reference in New Issue
Block a user