mirror of
				https://github.com/actions/setup-node.git
				synced 2025-10-31 16:14:00 +08:00 
			
		
		
		
	Add pnpm caching support
This commit is contained in:
		
							
								
								
									
										20
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -4290,6 +4290,11 @@ exports.supportedPackageManagers = { | ||||
|         lockFilePatterns: ['package-lock.json', 'yarn.lock'], | ||||
|         getCacheFolderCommand: 'npm config get cache' | ||||
|     }, | ||||
|     pnpm: { | ||||
|         lockFilePatterns: ['pnpm-lock.yaml'], | ||||
|         getCacheFolderCommand: 'pnpm get store', | ||||
|         defaultCacheFolder: '~/.pnpm-store' | ||||
|     }, | ||||
|     yarn1: { | ||||
|         lockFilePatterns: ['yarn.lock'], | ||||
|         getCacheFolderCommand: 'yarn cache dir' | ||||
| @@ -4304,7 +4309,7 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu | ||||
|     if (stderr) { | ||||
|         throw new Error(stderr); | ||||
|     } | ||||
|     return stdout; | ||||
|     return stdout.trim(); | ||||
| }); | ||||
| const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () { | ||||
|     const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`); | ||||
| @@ -4317,6 +4322,9 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo | ||||
|     if (packageManager === 'npm') { | ||||
|         return exports.supportedPackageManagers.npm; | ||||
|     } | ||||
|     else if (packageManager === 'pnpm') { | ||||
|         return exports.supportedPackageManagers.pnpm; | ||||
|     } | ||||
|     else if (packageManager === 'yarn') { | ||||
|         const yarnVersion = yield getPackageManagerVersion('yarn', '--version'); | ||||
|         core.debug(`Consumed yarn version is ${yarnVersion}`); | ||||
| @@ -4332,7 +4340,14 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo | ||||
|     } | ||||
| }); | ||||
| exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { | ||||
|     const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); | ||||
|     let stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); | ||||
|     // pnpm returns 'undefined' if no custom store path is set
 | ||||
|     if (stdOut === 'undefined') { | ||||
|         stdOut = ''; | ||||
|     } | ||||
|     if (!stdOut && packageManagerInfo.defaultCacheFolder) { | ||||
|         stdOut = packageManagerInfo.defaultCacheFolder; | ||||
|     } | ||||
|     if (!stdOut) { | ||||
|         throw new Error(`Could not get cache folder path for ${packageManager}`); | ||||
|     } | ||||
| @@ -5270,6 +5285,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var LockType; | ||||
| (function (LockType) { | ||||
|     LockType["Npm"] = "npm"; | ||||
|     LockType["Pnpm"] = "pnpm"; | ||||
|     LockType["Yarn"] = "yarn"; | ||||
| })(LockType = exports.LockType || (exports.LockType = {})); | ||||
| var State; | ||||
|   | ||||
							
								
								
									
										20
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -8652,6 +8652,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var LockType; | ||||
| (function (LockType) { | ||||
|     LockType["Npm"] = "npm"; | ||||
|     LockType["Pnpm"] = "pnpm"; | ||||
|     LockType["Yarn"] = "yarn"; | ||||
| })(LockType = exports.LockType || (exports.LockType = {})); | ||||
| var State; | ||||
| @@ -51587,6 +51588,11 @@ exports.supportedPackageManagers = { | ||||
|         lockFilePatterns: ['package-lock.json', 'yarn.lock'], | ||||
|         getCacheFolderCommand: 'npm config get cache' | ||||
|     }, | ||||
|     pnpm: { | ||||
|         lockFilePatterns: ['pnpm-lock.yaml'], | ||||
|         getCacheFolderCommand: 'pnpm get store', | ||||
|         defaultCacheFolder: '~/.pnpm-store' | ||||
|     }, | ||||
|     yarn1: { | ||||
|         lockFilePatterns: ['yarn.lock'], | ||||
|         getCacheFolderCommand: 'yarn cache dir' | ||||
| @@ -51601,7 +51607,7 @@ exports.getCommandOutput = (toolCommand) => __awaiter(void 0, void 0, void 0, fu | ||||
|     if (stderr) { | ||||
|         throw new Error(stderr); | ||||
|     } | ||||
|     return stdout; | ||||
|     return stdout.trim(); | ||||
| }); | ||||
| const getPackageManagerVersion = (packageManager, command) => __awaiter(void 0, void 0, void 0, function* () { | ||||
|     const stdOut = yield exports.getCommandOutput(`${packageManager} ${command}`); | ||||
| @@ -51614,6 +51620,9 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo | ||||
|     if (packageManager === 'npm') { | ||||
|         return exports.supportedPackageManagers.npm; | ||||
|     } | ||||
|     else if (packageManager === 'pnpm') { | ||||
|         return exports.supportedPackageManagers.pnpm; | ||||
|     } | ||||
|     else if (packageManager === 'yarn') { | ||||
|         const yarnVersion = yield getPackageManagerVersion('yarn', '--version'); | ||||
|         core.debug(`Consumed yarn version is ${yarnVersion}`); | ||||
| @@ -51629,7 +51638,14 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo | ||||
|     } | ||||
| }); | ||||
| exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { | ||||
|     const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); | ||||
|     let stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); | ||||
|     // pnpm returns 'undefined' if no custom store path is set
 | ||||
|     if (stdOut === 'undefined') { | ||||
|         stdOut = ''; | ||||
|     } | ||||
|     if (!stdOut && packageManagerInfo.defaultCacheFolder) { | ||||
|         stdOut = packageManagerInfo.defaultCacheFolder; | ||||
|     } | ||||
|     if (!stdOut) { | ||||
|         throw new Error(`Could not get cache folder path for ${packageManager}`); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jacob Gillespie
					Jacob Gillespie