Bugfix/java checks (#1228)

* fix: Java version parsing if java executable prints out additional information with --version

* fix: Ensure JAVA_HOME path comes first in the PATH environment

* refactor: Removed redundent code in favour of keeping a change introduced from another PR
This commit is contained in:
Norman Breau
2021-05-09 17:52:35 -03:00
committed by GitHub
parent ae4dba2bb8
commit 6d803e2f72
2 changed files with 16 additions and 7 deletions

View File

@@ -47,9 +47,19 @@ describe('Java', () => {
all: 'javac 1.8.0_275'
}));
console.log('BEFORE', process.env.JAVA_HOME);
const result = await Java.getVersion();
console.log('AFTER', process.env.JAVA_HOME);
expect(result.major).toBe(1);
expect(result.minor).toBe(8);
expect(result.patch).toBe(0);
expect(result.version).toBe('1.8.0');
});
it('detects JDK when additional details are printed', async () => {
Java.__set__('execa', () => Promise.resolve({
all: 'Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8\njavac 1.8.0_275'
}));
const result = await Java.getVersion();
expect(result.major).toBe(1);
expect(result.minor).toBe(8);
expect(result.patch).toBe(0);