2021-05-27 06:03:38 +02:00
|
|
|
export default function getURL(
|
|
|
|
|
os: string,
|
|
|
|
|
arch: string,
|
2025-01-03 17:36:35 -05:00
|
|
|
extended: boolean,
|
|
|
|
|
withdeploy: boolean,
|
2021-05-27 06:03:38 +02:00
|
|
|
version: string
|
|
|
|
|
): string {
|
2025-01-03 17:36:35 -05:00
|
|
|
|
|
|
|
|
const extendedStr = (extended: boolean): string => {
|
|
|
|
|
if (extended) {
|
2019-09-21 10:41:21 +09:00
|
|
|
return 'extended_';
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
// } else {
|
|
|
|
|
// throw new Error(`Invalid input (extended): ${extended}`);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-03 17:36:35 -05:00
|
|
|
const deployStr = (deploy: boolean): string => {
|
|
|
|
|
if (deploy) {
|
|
|
|
|
return 'withdeploy_';
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
// } else {
|
|
|
|
|
// throw new Error(`Invalid input (extended): ${extended}`);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-18 10:29:06 +09:00
|
|
|
const ext = (os: string): string => {
|
2019-09-21 10:41:21 +09:00
|
|
|
if (os === 'Windows') {
|
|
|
|
|
return 'zip';
|
|
|
|
|
} else {
|
|
|
|
|
return 'tar.gz';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-03 17:36:35 -05:00
|
|
|
const hugoName = `hugo_${extendedStr(extended)}${deployStr(withdeploy)}${version}_${os}-${arch}`;
|
2020-01-18 10:29:06 +09:00
|
|
|
const baseURL = 'https://github.com/gohugoio/hugo/releases/download';
|
|
|
|
|
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
|
2019-09-21 10:41:21 +09:00
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
}
|