mirror of https://github.com/actions/setup-go.git
Format files according to Prettier rules and build
This commit is contained in:
parent
25a133c257
commit
53f5d5ec02
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -12,16 +12,14 @@ import {
|
||||||
} from './cache-utils';
|
} from './cache-utils';
|
||||||
|
|
||||||
export const restoreCache = async (
|
export const restoreCache = async (
|
||||||
packageManager: string,
|
packageManager: string,
|
||||||
cacheDependencyPath?: string
|
cacheDependencyPath?: string
|
||||||
) => {
|
) => {
|
||||||
const packageManagerInfo = await getPackageManagerInfo();
|
const packageManagerInfo = await getPackageManagerInfo();
|
||||||
const platform = process.env.RUNNER_OS;
|
const platform = process.env.RUNNER_OS;
|
||||||
|
|
||||||
const cachePath = await getCacheDirectoryPath(
|
const cachePath = await getCacheDirectoryPath(packageManagerInfo);
|
||||||
packageManagerInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
const goSumFilePath = cacheDependencyPath
|
const goSumFilePath = cacheDependencyPath
|
||||||
? cacheDependencyPath
|
? cacheDependencyPath
|
||||||
: findGoSumFile(packageManagerInfo);
|
: findGoSumFile(packageManagerInfo);
|
||||||
|
|
|
@ -25,10 +25,8 @@ const cachePackages = async () => {
|
||||||
const primaryKey = core.getState(State.CachePrimaryKey);
|
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||||
|
|
||||||
const packageManagerInfo = await getPackageManagerInfo();
|
const packageManagerInfo = await getPackageManagerInfo();
|
||||||
|
|
||||||
const cachePath = await getCacheDirectoryPath(
|
const cachePath = await getCacheDirectoryPath(packageManagerInfo);
|
||||||
packageManagerInfo,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!fs.existsSync(cachePath)) {
|
if (!fs.existsSync(cachePath)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
|
@ -7,8 +7,8 @@ export interface PackageManagerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultPackageManager: PackageManagerInfo = {
|
export const defaultPackageManager: PackageManagerInfo = {
|
||||||
goSumFilePattern: 'go.sum',
|
goSumFilePattern: 'go.sum',
|
||||||
getCacheFolderCommand: 'go env GOMODCACHE',
|
getCacheFolderCommand: 'go env GOMODCACHE'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCommandOutput = async (toolCommand: string) => {
|
export const getCommandOutput = async (toolCommand: string) => {
|
||||||
|
@ -29,17 +29,15 @@ export const getCommandOutput = async (toolCommand: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPackageManagerInfo = async () => {
|
export const getPackageManagerInfo = async () => {
|
||||||
|
|
||||||
return defaultPackageManager;
|
return defaultPackageManager;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCacheDirectoryPath = async (
|
export const getCacheDirectoryPath = async (
|
||||||
packageManagerInfo: PackageManagerInfo,
|
packageManagerInfo: PackageManagerInfo
|
||||||
) => {
|
) => {
|
||||||
const stdout = await getCommandOutput(
|
const stdout = await getCommandOutput(
|
||||||
packageManagerInfo.getCacheFolderCommand
|
packageManagerInfo.getCacheFolderCommand
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!stdout) {
|
if (!stdout) {
|
||||||
throw new Error(`Could not get cache folder path.`);
|
throw new Error(`Could not get cache folder path.`);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as core from '@actions/core';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as installer from './installer';
|
import * as installer from './installer';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {restoreCache} from './cache-restore';
|
import {restoreCache} from './cache-restore';
|
||||||
import cp from 'child_process';
|
import cp from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {URL} from 'url';
|
import {URL} from 'url';
|
||||||
|
@ -14,7 +14,7 @@ export async function run() {
|
||||||
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
// If not supplied then problem matchers will still be setup. Useful for self-hosted.
|
||||||
//
|
//
|
||||||
let versionSpec = core.getInput('go-version');
|
let versionSpec = core.getInput('go-version');
|
||||||
|
|
||||||
// stable will be true unless false is the exact input
|
// stable will be true unless false is the exact input
|
||||||
// since getting unstable versions should be explicit
|
// since getting unstable versions should be explicit
|
||||||
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
let stable = (core.getInput('stable') || 'true').toUpperCase() === 'TRUE';
|
||||||
|
|
Loading…
Reference in New Issue