diff --git a/.gitignore b/.gitignore index 2abd1072..68102372 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,6 @@ Desktop.ini *.iml .idea npm-debug.log -/framework/build node_modules/jshint node_modules/promise-matchers node_modules/jasmine-node diff --git a/bin/templates/cordova/lib/AndroidStudio.js b/bin/templates/cordova/lib/AndroidStudio.js index 89c4c858..3b1e3d41 100644 --- a/bin/templates/cordova/lib/AndroidStudio.js +++ b/bin/templates/cordova/lib/AndroidStudio.js @@ -8,15 +8,20 @@ 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', 'build', 'app/src/main/assets']; + var androidStudioFiles = ['app', 'gradle', 'build', '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))) { diff --git a/spec/fixtures/android_studio_project/app/build/placeholder b/spec/fixtures/android_studio_project/app/build/placeholder new file mode 100644 index 00000000..8b6d9e2d --- /dev/null +++ b/spec/fixtures/android_studio_project/app/build/placeholder @@ -0,0 +1 @@ +Tests require that this folder exists. \ No newline at end of file diff --git a/spec/unit/AndroidStudio.js b/spec/unit/AndroidStudio.js deleted file mode 100644 index 74c11f29..00000000 --- a/spec/unit/AndroidStudio.js +++ /dev/null @@ -1,14 +0,0 @@ -var AndroidStudio = require('../../bin/templates/cordova/lib/AndroidStudio'); - -describe('AndroidStudio module', function () { - it('should detect Android Studio project', function() { - var root = './fixtures/android_studio_project'; - spyOn(AndroidStudio, 'isAndroidStudioProject').andReturn(true); - AndroidStudio.isAndroidStudioProject(root); - }); - it('should detect non Android Studio project', function() { - var root = './fixtures/android_project'; - spyOn(AndroidStudio, 'isAndroidStudioProject').andReturn(false); - AndroidStudio.isAndroidStudioProject(root); - }); -}); diff --git a/spec/unit/AndroidStudio.spec.js b/spec/unit/AndroidStudio.spec.js new file mode 100644 index 00000000..95d5f4b7 --- /dev/null +++ b/spec/unit/AndroidStudio.spec.js @@ -0,0 +1,17 @@ + +var path = require('path'); +var AndroidStudio = require('../../bin/templates/cordova/lib/AndroidStudio'); + + +describe('AndroidStudio module', function () { + it('should return true for Android Studio project', function() { + var root = path.join(__dirname,'../fixtures/android_studio_project/'); + var isAndStud = AndroidStudio.isAndroidStudioProject(root); + expect(isAndStud).toBe(true); + }); + it('should return false non Android Studio project', function() { + var root = path.join(__dirname,'../fixtures/android_project/'); + var isAndStud = AndroidStudio.isAndroidStudioProject(root); + expect(isAndStud).toBe(false); + }); +});