Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fetch java executable location from PATH if JAVA_HOME is unset #573

Merged
merged 4 commits into from
Aug 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the error message
  • Loading branch information
mykola-mokhnach committed Aug 4, 2021
commit 7091401a1167657fa66ce17b1c473614c85005a1
7 changes: 2 additions & 5 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,8 @@ const getJavaForOs = _.memoize(async function getJavaForOs () {
try {
return await fs.which(executableName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we generalize this for other binaries, not just java?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which binaries exactly you'd like to generalize?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure, don't we do similar logic currently for binaries inside ANDROID_HOME, and, e.g., jarsigner?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jarsigner is only used as a fallback if apksigner fails for some reason, so I would rather leave it as is for now

} catch (err) {
let message = `${executableName} could not be found neither in PATH nor under JAVA_HOME`;
if (errMsg) {
message += ` (${errMsg})`;
}
throw new Error(message);
throw new Error(`${executableName} could not be found neither in PATH nor under JAVA_HOME ` +
`(${errMsg || javaHome})`);
}
});

Expand Down