fix(regression): Cannot read version of undefined caused by Java refactor (https://github.com/apache/cordova-android/pull/1130#discussion_r563597125) (#1185)

This commit is contained in:
Norman Breau 2021-03-30 10:40:34 -03:00 committed by GitHub
parent d22af021ee
commit 1ec87634d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -135,6 +135,8 @@ module.exports.check_gradle = function () {
/**
* Checks for the java installation and correct version
*
* Despite the name, it should return the Java version value, it's used by the Cordova CLI.
*/
module.exports.check_java = async function () {
const javaVersion = await java.getVersion();
@ -145,6 +147,8 @@ module.exports.check_java = async function () {
'Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.'
);
}
return javaVersion;
};
// Returns a promise.

View File

@ -56,6 +56,14 @@ describe('check_reqs', function () {
await expectAsync(check_reqs.check_java()).toBeRejectedWithError(CordovaError, /Requirements check failed for JDK 9999.9999.9999! Detected version: 1.8.0/);
});
it('should return the version', async () => {
check_reqs.__set__({
java: { getVersion: async () => ({ version: '1.8.0' }) }
});
await expectAsync(check_reqs.check_java()).toBeResolvedTo({ version: '1.8.0' });
});
});
describe('check_android', function () {