mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-01 00:23:59 +08:00 
			
		
		
		
	Add logic to check that cache folder exists
This commit is contained in:
		| @@ -1,5 +1,8 @@ | |||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import * as exec from '@actions/exec'; | import * as exec from '@actions/exec'; | ||||||
|  | import fs from 'fs'; | ||||||
|  | import os from 'os'; | ||||||
|  | import path from 'path'; | ||||||
|  |  | ||||||
| type SupportedPackageManagers = { | type SupportedPackageManagers = { | ||||||
|   [prop: string]: PackageManagerInfo; |   [prop: string]: PackageManagerInfo; | ||||||
| @@ -19,7 +22,7 @@ export const supportedPackageManagers: SupportedPackageManagers = { | |||||||
|   pnpm: { |   pnpm: { | ||||||
|     lockFilePatterns: ['pnpm-lock.yaml'], |     lockFilePatterns: ['pnpm-lock.yaml'], | ||||||
|     getCacheFolderCommand: 'pnpm get store', |     getCacheFolderCommand: 'pnpm get store', | ||||||
|     defaultCacheFolder: '~/.pnpm-store' |     defaultCacheFolder: path.join(os.homedir(), '.pnpm-store') | ||||||
|   }, |   }, | ||||||
|   yarn1: { |   yarn1: { | ||||||
|     lockFilePatterns: ['yarn.lock'], |     lockFilePatterns: ['yarn.lock'], | ||||||
| @@ -95,5 +98,11 @@ export const getCacheDirectoryPath = async ( | |||||||
|  |  | ||||||
|   core.debug(`${packageManager} path is ${stdOut}`); |   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; |   return stdOut; | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jacob Gillespie
					Jacob Gillespie