Skip to content

Commit

Permalink
Fix file extension for Windows platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
hybloid committed Nov 14, 2023
1 parent 7bbe9bf commit 7440472
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions vscode/qodana/src/core/jdk/jbrDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export async function extractJbr(filePath: string, releaseName: string, extractP
cwd: extractPath
});
let dirName = releaseName.replace('.tar.gz', '');
if (getOsAndArch().osType === 'osx') {
let osType = getOsAndArch().osType;
if (osType === 'osx') {
return path.join(extractPath, dirName, 'Contents', 'Home', 'bin', 'java');
}
return path.join(extractPath, dirName, 'bin', 'java');
return path.join(extractPath, dirName, 'bin', 'java' + (osType === 'windows' ? '.exe' : ''));
} catch (e) {
vscode.window.showErrorMessage(failedToDownloadJbr(filePath) + `: ${e}`);
telemetry.errorReceived('#extractJbr exception');
Expand Down Expand Up @@ -180,11 +181,11 @@ export async function getJavaForExecution(context: vscode.ExtensionContext): Pro
await context.globalState.update('javaExecutablePath', undefined);
}
}
let localJava = getJavaExecutablePath();
if (localJava) {
await context.globalState.update('javaExecutablePath', localJava);
return localJava;
}
//let localJava = getJavaExecutablePath();
//if (localJava) {
// await context.globalState.update('javaExecutablePath', localJava);
// return localJava;
//}
let decision = await vscode.window.showErrorMessage(DOWNLOAD_CONFIRMATION, YES, NO);
if (decision === YES) {
let downloadedJbrDir = path.join(context.globalStorageUri.fsPath, Math.random().toString(36).substring(7));
Expand Down
2 changes: 2 additions & 0 deletions vscode/qodana/src/test/suite/jdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('JBR Downloader', () => {
await fs.promises.access(javaPath!);
assert.strictEqual(javaPath!.endsWith('java') || javaPath!.endsWith('java.exe'), true);
} catch (e) {
assert.fail('Failed to download and unpack the JBR');
} finally {
await fs.promises.rm(tempDirName, { recursive: true });
}
});
Expand Down

0 comments on commit 7440472

Please sign in to comment.