diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-02-16 01:24:12 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-02-16 01:24:12 +0100 |
| commit | 30c49550c89c1b69c680170d2dc247eac76bd463 (patch) | |
| tree | 8732652298b630b9ba15def97e59738f1c9bf7b6 /StoneIsland/platforms/android/cordova/lib/AndroidStudio.js | |
| parent | 8f1f626384e6ba75f4fb24c27e0973260a74421b (diff) | |
push plugin
Diffstat (limited to 'StoneIsland/platforms/android/cordova/lib/AndroidStudio.js')
| -rw-r--r-- | StoneIsland/platforms/android/cordova/lib/AndroidStudio.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/cordova/lib/AndroidStudio.js b/StoneIsland/platforms/android/cordova/lib/AndroidStudio.js new file mode 100644 index 00000000..335b334b --- /dev/null +++ b/StoneIsland/platforms/android/cordova/lib/AndroidStudio.js @@ -0,0 +1,42 @@ +/* + * This is a simple routine that checks if project is an Android Studio Project + * + * @param {String} root Root folder of the project + */ + +/*jshint esnext: false */ + +var path = require('path'); +var fs = require('fs'); +var CordovaError = require('cordova-common').CordovaError; + +module.exports.isAndroidStudioProject = function isAndroidStudioProject(root) { + var eclipseFiles = ['AndroidManifest.xml', 'libs', 'res', 'project.properties', 'platform_www']; + var androidStudioFiles = ['app', 'gradle', 'app/src/main/res']; + + // assume it is an AS project and not an Eclipse project + var isEclipse = false; + var isAS = true; + + if(!fs.existsSync(root)) { + throw new CordovaError('AndroidStudio.js:inAndroidStudioProject root does not exist: ' + root); + } + + // 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))) { + console.log('missing file :: ' + file); + isAS = false; + } + }); + } + return (!isEclipse && isAS); +}; |
