3
0
Fork 0
mirror of https://gitea.com/actions/setup-node.git synced 2024-11-25 11:39:32 +01:00

Move existence check to cache-save

This commit is contained in:
Jacob Gillespie 2021-07-14 15:25:45 +01:00
parent d278e78bdd
commit 399982b368
No known key found for this signature in database
GPG key ID: 52D71192EF3DBDD9
2 changed files with 8 additions and 7 deletions

View file

@ -1,5 +1,6 @@
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';
@ -26,6 +27,13 @@ const cachePackages = async (packageManager: string) => {
packageManagerInfo,
packageManager
);
if (!fs.existsSync(cachePath)) {
throw new Error(
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePath}`
);
}
if (primaryKey === state) {
core.info(
`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`

View file

@ -1,6 +1,5 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import fs from 'fs';
import os from 'os';
import path from 'path';
@ -98,11 +97,5 @@ export const getCacheDirectoryPath = async (
core.debug(`${packageManager} path is ${stdOut}`);
if (!fs.existsSync(stdOut)) {
throw new Error(
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${stdOut}`
);
}
return stdOut;
};