diff --git a/lib/installer.js b/lib/installer.js index 7323e893..30d76bdc 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -47,11 +47,13 @@ function getJava(version, arch, jdkFile) { core.debug(`Tool found in cache ${toolPath}`); } else { + let compressedFileExtension = ''; if (!jdkFile) { jdkFile = yield downloadJava(version); + compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz'; } core.debug('Retrieving Jdk from local path'); - const compressedFileExtension = getFileEnding(jdkFile); + compressedFileExtension = compressedFileExtension || getFileEnding(jdkFile); let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000)); const jdkDir = yield unzipJavaDownload(jdkFile, compressedFileExtension, tempDir); core.debug(`jdk extracted to ${jdkDir}`); @@ -127,7 +129,7 @@ function unpackJars(fsPath, javaBinPath) { } }); } -function unzipJavaDownload(repoRoot, fileEnding, destinationFolder) { +function unzipJavaDownload(repoRoot, fileEnding, destinationFolder, extension) { return __awaiter(this, void 0, void 0, function* () { // Create the destination folder if it doesn't exist yield io.mkdirP(destinationFolder); @@ -170,10 +172,6 @@ function downloadJava(version) { throw new Error(`No valid download found for version ${version}. Check https://static.azul.com/zulu/bin/ for a list of valid versions or download your own jdk file and add the jdkFile argument`); } const fileName = refs[0].slice(''.length); - const dest = yield tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`); - if (dest) { - throw new Error(fs.readdirSync(dest).toString()); - } - return path.join(dest, fileName); + return yield tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`); }); } diff --git a/src/installer.ts b/src/installer.ts index af513668..bf5d2163 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -35,11 +35,13 @@ export async function getJava( if (toolPath) { core.debug(`Tool found in cache ${toolPath}`); } else { + let compressedFileExtension = ''; if (!jdkFile) { jdkFile = await downloadJava(version); + compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz'; } core.debug('Retrieving Jdk from local path'); - const compressedFileExtension = getFileEnding(jdkFile); + compressedFileExtension = compressedFileExtension || getFileEnding(jdkFile); let tempDir: string = path.join( tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000) @@ -123,7 +125,8 @@ async function unpackJars(fsPath: string, javaBinPath: string) { async function unzipJavaDownload( repoRoot: string, fileEnding: string, - destinationFolder: string + destinationFolder: string, + extension?: string ): Promise { // Create the destination folder if it doesn't exist await io.mkdirP(destinationFolder); @@ -175,11 +178,5 @@ async function downloadJava(version: string): Promise { ''.length ); - const dest = await tc.downloadTool( - `https://static.azul.com/zulu/bin/${fileName}` - ); - if (dest) { - throw new Error(fs.readdirSync(dest).toString()); - } - return path.join(dest, fileName); + return await tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`); }