Skip to content

Commit

Permalink
climate
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudlevy committed Nov 5, 2024
1 parent 153e0fe commit c6275e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 35 deletions.
57 changes: 23 additions & 34 deletions src/get-url.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
export default function getURL(
os: string,
arch: string,
extended: string,
withdeploy: string,
version: string
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_';
}
let withdeployStr = '';
if (options..withdeploy === 'true') {
withdeployStr = 'withdeploy_';
}
let ext = 'tar.gz';
if (system.os === 'Windows') {
ext = 'zip';
}

const withdeployStr = (withdeploy: string): string => {
if (withdeploy === 'true') {
return 'withdeploy_';
} else {
return '';
// } else {
// throw new Error(`Invalid input (withdeploy): ${withdeploy}`);
}
};

const ext = (os: string): string => {
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
}
};

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;
}
5 changes: 4 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c6275e7

Please sign in to comment.