mirror of
https://github.com/actions/setup-go.git
synced 2025-07-18 21:05:15 -06:00
Change code to make it more extandable in future
This commit is contained in:
parent
d450effe85
commit
f2efd31d13
7 changed files with 75 additions and 44 deletions
|
@ -1,13 +1,19 @@
|
|||
import * as exec from '@actions/exec';
|
||||
|
||||
type SupportedPackageManagers = {
|
||||
[prop: string]: PackageManagerInfo;
|
||||
};
|
||||
|
||||
export interface PackageManagerInfo {
|
||||
goSumFilePattern: string;
|
||||
dependencyFilePattern: string;
|
||||
getCacheFolderCommand: string;
|
||||
}
|
||||
|
||||
export const defaultPackageManager: PackageManagerInfo = {
|
||||
goSumFilePattern: 'go.sum',
|
||||
getCacheFolderCommand: 'go env GOMODCACHE'
|
||||
export const supportedPackageManagers: SupportedPackageManagers = {
|
||||
default: {
|
||||
dependencyFilePattern: 'go.sum',
|
||||
getCacheFolderCommand: 'go env GOMODCACHE'
|
||||
}
|
||||
};
|
||||
|
||||
export const getCommandOutput = async (toolCommand: string) => {
|
||||
|
@ -27,8 +33,14 @@ export const getCommandOutput = async (toolCommand: string) => {
|
|||
return stdout.trim();
|
||||
};
|
||||
|
||||
export const getPackageManagerInfo = async () => {
|
||||
return defaultPackageManager;
|
||||
export const getPackageManagerInfo = async (packageManager: string) => {
|
||||
if (!supportedPackageManagers.packageManager) {
|
||||
throw new Error(
|
||||
`It's not possible to use ${packageManager}, please, check correctness of the package manager name spelling.`
|
||||
);
|
||||
}
|
||||
|
||||
return supportedPackageManagers.packageManager;
|
||||
};
|
||||
|
||||
export const getCacheDirectoryPath = async (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue