mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2025-06-18 01:55:29 +08:00

This commit introduces the getConventions function, which does a one-time calculation for the changes in packaging conventions to propagate to the getArch and getOS functions. It updates those functions and the installer code to leverage the conventions. Finally, it updates the test arrangement for getArch and getOS to use test cases instead of repeating the same test over and over and adds unit tests for the new getConventions function.
16 lines
474 B
TypeScript
16 lines
474 B
TypeScript
import { conventions } from "./get-conventions";
|
|
|
|
export default function getOS(platform: string, conventions: conventions): string {
|
|
|
|
switch (platform) {
|
|
case 'linux':
|
|
return conventions.os.downcasedAll ? 'linux' : 'Linux'
|
|
case 'darwin':
|
|
return conventions.os.renamedMacOS ? 'darwin' : 'macOS'
|
|
case 'win32':
|
|
return conventions.os.downcasedAll ? 'windows' : 'Windows'
|
|
default:
|
|
throw new Error(`${platform} is not supported`);
|
|
}
|
|
}
|