Fix pathing

This commit is contained in:
Danny McCormick 2019-07-15 13:48:23 -04:00
parent d04dab381d
commit 1d110a99d1
2 changed files with 12 additions and 10 deletions

View file

@ -48,8 +48,7 @@ function getJava(version, arch, jdkFile) {
}
else {
if (!jdkFile) {
const downloadUrl = yield getDownloadUrl(version);
jdkFile = yield tc.downloadTool(downloadUrl);
jdkFile = yield downloadJava(version);
}
core.debug('Retrieving Jdk from local path');
const compressedFileExtension = getFileEnding(jdkFile);
@ -145,7 +144,7 @@ function unzipJavaDownload(repoRoot, fileEnding, destinationFolder) {
}
});
}
function getDownloadUrl(version) {
function downloadJava(version) {
return __awaiter(this, void 0, void 0, function* () {
let filterString = '';
if (IS_WINDOWS) {
@ -170,7 +169,8 @@ function getDownloadUrl(version) {
if (refs.length == 0) {
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 downloadLocation = refs[0].slice('<a href="'.length, refs[0].length - '">'.length);
return `https://static.azul.com/zulu/bin/${downloadLocation}`;
const fileName = refs[0].slice('<a href="'.length, refs[0].length - '">'.length);
const dest = yield tc.downloadTool(`https://static.azul.com/zulu/bin/${fileName}`);
return path.join(dest, fileName);
});
}

View file

@ -36,8 +36,7 @@ export async function getJava(
core.debug(`Tool found in cache ${toolPath}`);
} else {
if (!jdkFile) {
const downloadUrl: string = await getDownloadUrl(version);
jdkFile = await tc.downloadTool(downloadUrl);
jdkFile = await downloadJava(version);
}
core.debug('Retrieving Jdk from local path');
const compressedFileExtension = getFileEnding(jdkFile);
@ -144,7 +143,7 @@ async function unzipJavaDownload(
}
}
async function getDownloadUrl(version: string) {
async function downloadJava(version: string): Promise<string> {
let filterString = '';
if (IS_WINDOWS) {
filterString = `jdk${version}-win_x64.zip`;
@ -172,9 +171,12 @@ async function getDownloadUrl(version: string) {
);
}
const downloadLocation = refs[0].slice(
const fileName = refs[0].slice(
'<a href="'.length,
refs[0].length - '">'.length
);
return `https://static.azul.com/zulu/bin/${downloadLocation}`;
const dest = await tc.downloadTool(
`https://static.azul.com/zulu/bin/${fileName}`
);
return path.join(dest, fileName);
}