This commit is contained in:
Arnaud Levy 2024-11-05 08:43:45 +01:00
parent 153e0fe512
commit c6275e7b7c
2 changed files with 27 additions and 35 deletions

View File

@ -1,41 +1,30 @@
export default function getURL(
system: {
os: string,
arch: string,
},
options: {
extended: string,
withdeploy: string,
version: string
}
): string {
const extendedStr = (extended: string): string => {
if (extended === 'true') {
return 'extended_';
} else {
return '';
// } else {
// throw new Error(`Invalid input (extended): ${extended}`);
let extendedStr = '';
if (options.extended === 'true') {
extendedStr = 'extended_';
}
};
const withdeployStr = (withdeploy: string): string => {
if (withdeploy === 'true') {
return 'withdeploy_';
} else {
return '';
// } else {
// throw new Error(`Invalid input (withdeploy): ${withdeploy}`);
let withdeployStr = '';
if (options..withdeploy === 'true') {
withdeployStr = 'withdeploy_';
}
};
const ext = (os: string): string => {
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
let ext = 'tar.gz';
if (system.os === 'Windows') {
ext = 'zip';
}
};
const hugoName = `hugo_${extendedStr(extended)}${withdeployStr(withdeploy)}${version}_${os}-${arch}`;
const hugoName = `hugo_${extendedStr}${withdeployStr}${options.version}_${system.os}-${system.arch}`;
const baseURL = 'https://github.com/gohugoio/hugo/releases/download';
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
const url = `${baseURL}/v${options.version}/${hugoName}.${ext}`;
return url;
}

View File

@ -56,7 +56,10 @@ export async function installer(version: string): Promise<void> {
const archName: string = getArch(process.arch);
core.debug(`Processor Architecture: ${archName}`);
const toolURL: string = getURL(osName, archName, extended, withdeploy, version);
const system = { os: osName, arch: archName };
const options = { extended: extended, withdeploy: withdeploy, version: version }
const toolURL: string = getURL(system, options);
core.debug(`toolURL: ${toolURL}`);
const workDir = await createWorkDir();