Skip to content

Commit

Permalink
refactor(env/java): shorten excessive comment
Browse files Browse the repository at this point in the history
  • Loading branch information
raphinesse committed Jun 23, 2021
1 parent 9f1f29f commit 5effa2d
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions bin/templates/cordova/lib/env/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,9 @@ const java = {
throw new CordovaError(msg);
}

/*
A regex match for the java version looks like the following:
version: [
'javac 1.8.0',
'1.8.0',
index: 45,
input: 'Picked up _JAVA_OPTIONS: -Xms1024M -Xmx2048M\njavac 1.8.0_271',
groups: undefined
]
We have to use a regular expression to get the java version, because on some environments
(e.g. macOS Big Sur) javac prints _JAVA_OPTIONS before printing the version and semver.coerce()
will fail to get the correct version from the output.
*/

// We have to filter the output, because javac prints _JAVA_OPTIONS
// before printing the version which causes semver.coerce to fail to get
// the correct version if those options contain any numbers.
const match = /javac\s+([\d.]+)/i.exec(javacOutput);
return semver.coerce(match && match[1]);
},
Expand Down

0 comments on commit 5effa2d

Please sign in to comment.