mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-23 00:00:09 +08:00
fix(requirements check): use regex to get java version from javac output (#1220)
* fix(requirements check): use regex to get java version from javac output * fix(lint): format code * fix(node 10): remove optional chaining from version check
This commit is contained in:
@@ -64,6 +64,25 @@ describe('check_reqs', function () {
|
||||
|
||||
await expectAsync(check_reqs.check_java()).toBeResolvedTo({ version: '1.8.0' });
|
||||
});
|
||||
|
||||
it('should return the correct version if javac prints _JAVA_OPTIONS', async () => {
|
||||
check_reqs.__set__({
|
||||
java: {
|
||||
getVersion: async () => {
|
||||
let version = null;
|
||||
const javacOutput = 'Picked up _JAVA_OPTIONS: -Xms1024M -Xmx2048M\njavac 1.8.0_271';
|
||||
const match = /javac\s+([\d.]+)/i.exec(javacOutput);
|
||||
if (match && match[1]) {
|
||||
version = match[1];
|
||||
}
|
||||
|
||||
return { version };
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await expectAsync(check_reqs.check_java()).toBeResolvedTo({ version: '1.8.0' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('check_android', function () {
|
||||
|
||||
Reference in New Issue
Block a user