Skip to content

Commit

Permalink
Update getJavaHome on JdkHelper.ts
Browse files Browse the repository at this point in the history
Update support for darwin by checking path and not duplicating /Contents/Home
  • Loading branch information
HashibulAmin authored Feb 9, 2025
1 parent 9ba50ce commit 262200e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/core/src/lib/jdk/JdkHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ export class JdkHelper {
* @param {Config} config The bubblewrap general configuration
* @param {NodeJS.Process} process Information from the OS process
*/
static getJavaHome(jdkPath: string, process: NodeJS.Process): string {
static getJavaHome(jdkPath, process) {
const joinPath = (process.platform === 'win32') ? path.win32.join : path.posix.join;
if (process.platform === 'darwin') {
return joinPath(jdkPath, '/Contents/Home/');
} else if (process.platform === 'linux' || process.platform === 'win32') {
return joinPath(jdkPath, '/');
}
if (process.platform === 'darwin') {
// If jdkPath already ends with '/Contents/Home' (with or without a trailing slash), return as is.
if (jdkPath.endsWith('/Contents/Home') || jdkPath.endsWith('/Contents/Home/')) {
return jdkPath;
}
return joinPath(jdkPath, '/Contents/Home/');
} else if (process.platform === 'linux' || process.platform === 'win32') {
return joinPath(jdkPath, '/');
}
throw new Error(`Unsupported Platform: ${process.platform}`);
}

Expand Down

0 comments on commit 262200e

Please sign in to comment.