Skip to content

Commit d278e78

Browse files
Add logic to check that cache folder exists
1 parent fdbc93e commit d278e78

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cache-utils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as core from '@actions/core';
22
import * as exec from '@actions/exec';
3+
import fs from 'fs';
4+
import os from 'os';
5+
import path from 'path';
36

47
type SupportedPackageManagers = {
58
[prop: string]: PackageManagerInfo;
@@ -19,7 +22,7 @@ export const supportedPackageManagers: SupportedPackageManagers = {
1922
pnpm: {
2023
lockFilePatterns: ['pnpm-lock.yaml'],
2124
getCacheFolderCommand: 'pnpm get store',
22-
defaultCacheFolder: '~/.pnpm-store'
25+
defaultCacheFolder: path.join(os.homedir(), '.pnpm-store')
2326
},
2427
yarn1: {
2528
lockFilePatterns: ['yarn.lock'],
@@ -95,5 +98,11 @@ export const getCacheDirectoryPath = async (
9598

9699
core.debug(`${packageManager} path is ${stdOut}`);
97100

101+
if (!fs.existsSync(stdOut)) {
102+
throw new Error(
103+
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${stdOut}`
104+
);
105+
}
106+
98107
return stdOut;
99108
};

0 commit comments

Comments
 (0)