use `getCurrentPackageManager` and `isCacheEnabled`

pull/321/head
Sergey Dolin 2 years ago
parent 03f925ed17
commit b179378e1e

@ -2,7 +2,12 @@ import * as core from '@actions/core';
import * as cache from '@actions/cache';
import fs from 'fs';
import {State} from './constants';
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
import {
getCacheDirectoryPath,
getPackageManagerInfo,
isCacheEnabled
} from './cache-utils';
import {getCurrentPackageManager} from './package-managers';
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
@ -28,12 +33,11 @@ export async function run() {
}
const cachePackages = async () => {
const cacheInput = core.getBooleanInput('cache');
if (!cacheInput) {
if (!(await isCacheEnabled())) {
return;
}
const packageManager = 'default';
const packageManager = getCurrentPackageManager();
const state = core.getState(State.CacheMatchedKey);
const primaryKey = core.getState(State.CachePrimaryKey);

@ -4,10 +4,11 @@ import * as installer from './installer';
import * as semver from 'semver';
import path from 'path';
import {restoreCache} from './cache-restore';
import {isCacheFeatureAvailable} from './cache-utils';
import {isCacheEnabled, isCacheFeatureAvailable} from './cache-utils';
import cp from 'child_process';
import fs from 'fs';
import os from 'os';
import {getCurrentPackageManager} from './package-managers';
export async function run() {
try {
@ -17,7 +18,6 @@ export async function run() {
//
const versionSpec = resolveVersionInput();
const cache = core.getBooleanInput('cache');
core.info(`Setup go version spec ${versionSpec}`);
let arch = core.getInput('architecture');
@ -59,8 +59,8 @@ export async function run() {
let goPath = await io.which('go');
let goVersion = (cp.execSync(`${goPath} version`) || '').toString();
if (cache && isCacheFeatureAvailable()) {
const packageManager = 'default';
if ((await isCacheEnabled()) && isCacheFeatureAvailable()) {
const packageManager = getCurrentPackageManager();
const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(
parseGoVersion(goVersion),

Loading…
Cancel
Save