mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
parent
48940bf4c0
commit
36646eb527
39
bin/templates/cordova/lib/AndroidStudio.js
vendored
39
bin/templates/cordova/lib/AndroidStudio.js
vendored
@ -4,26 +4,33 @@
|
||||
* @param {String} root Root folder of the project
|
||||
*/
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
/*jshint esnext: false */
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function isAndroidStudioProject(root) {
|
||||
module.exports.isAndroidStudioProject = function isAndroidStudioProject(root) {
|
||||
var eclipseFiles = ['AndroidManifest.xml', 'libs', 'res', 'project.properties', 'platform_www'];
|
||||
var androidStudioFiles = ['app', 'gradle', 'build', 'app/src/main/assets'];
|
||||
var file;
|
||||
for(file of eclipseFiles) {
|
||||
if(fs.existsSync(path.join(root, file))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for(file of androidStudioFiles) {
|
||||
if(!fs.existsSync(path.join(root, file))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports.isAndroidStudioProject = isAndroidStudioProject;
|
||||
// assume it is an AS project and not an Eclipse project
|
||||
var isEclipse = false;
|
||||
var isAS = true;
|
||||
|
||||
// if any of the following exists, then we are not an ASProj
|
||||
eclipseFiles.forEach(function(file) {
|
||||
if(fs.existsSync(path.join(root, file))) {
|
||||
isEclipse = true;
|
||||
}
|
||||
});
|
||||
|
||||
// if it is NOT an eclipse project, check that all required files exist
|
||||
if(!isEclipse) {
|
||||
androidStudioFiles.forEach(function(file){
|
||||
if(!fs.existsSync(path.join(root, file))) {
|
||||
isAS = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
return (!isEclipse && isAS);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user