Skip to content

Commit

Permalink
Add logic to check that cache folder exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Jul 14, 2021
1 parent fdbc93e commit d278e78
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cache-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import fs from 'fs';
import os from 'os';
import path from 'path';

type SupportedPackageManagers = {
[prop: string]: PackageManagerInfo;
Expand All @@ -19,7 +22,7 @@ export const supportedPackageManagers: SupportedPackageManagers = {
pnpm: {
lockFilePatterns: ['pnpm-lock.yaml'],
getCacheFolderCommand: 'pnpm get store',
defaultCacheFolder: '~/.pnpm-store'
defaultCacheFolder: path.join(os.homedir(), '.pnpm-store')
},
yarn1: {
lockFilePatterns: ['yarn.lock'],
Expand Down Expand Up @@ -95,5 +98,11 @@ 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;
};

0 comments on commit d278e78

Please sign in to comment.