Compare commits

...
Author SHA1 Message Date
Dominik Sokal 2555e45062 update CHANGELOG 2019-10-28 11:07:47 +01:00
Dominik Sokal 1cae1cbc79 [turtle-cli] enforce java 8 2019-10-28 11:03:15 +01:00
2 changed files with 18 additions and 3 deletions

No files matched your search

+3
View File
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased
### Changed
- Enforce Java 8 when using turtle-cli.
## [0.12.7] - 2019-10-25
### Changed
+15 -3
View File
@@ -15,6 +15,7 @@ import { PLATFORMS } from 'turtle/constants';
import logger from 'turtle/logger';
const which = util.promisify(_which);
const JAVA_REQUIRED_VERSION = 8;
const REQUIRED_TOOLS: IToolDefinition[] = [
{
command: 'bash',
@@ -22,16 +23,27 @@ const REQUIRED_TOOLS: IToolDefinition[] = [
},
{
command: 'javac',
missingDescription: 'Please install JDK (version 8 or newer) - check https://jdk.java.net/',
missingDescription: `Please install JDK (version ${JAVA_REQUIRED_VERSION}) - check https://jdk.java.net/`,
testFn: async () => {
const { status, stdout } = await ExponentTools.spawnAsyncThrowError(
'javac',
const { status, stdout, stderr } = await ExponentTools.spawnAsyncThrowError(
'java',
['-version'],
{ stdio: 'pipe' },
);
if (stdout.match(/no java runtime present/i)) {
return false;
}
const matchResult = stderr.match(/.*version ".*\.(.*)\..*"/);
if (matchResult) {
const [, currentJavaVersion] = matchResult;
if (Number(currentJavaVersion) !== JAVA_REQUIRED_VERSION) {
throw new Error(`You're using a wrong Java version, please install version ${JAVA_REQUIRED_VERSION}`);
}
} else {
logger.warn(`Couldn't find Java version number, assuming you're on Java ${JAVA_REQUIRED_VERSION}...`);
}
return status === 0;
},
},