From 3af302a4f220de9ff48cd21cc1ab8e9c54382600 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Thu, 15 Jul 2021 12:43:19 +0100 Subject: [PATCH] Switch to pnpm store path command --- README.md | 6 ++++-- dist/cache-save/index.js | 17 ++--------------- dist/setup/index.js | 17 ++--------------- src/cache-utils.ts | 17 ++++------------- 4 files changed, 12 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 847fff84..58997afc 100644 --- a/README.md +++ b/README.md @@ -55,18 +55,20 @@ steps: - run: npm test ``` -**Caching pnpm dependencies:** +**Caching pnpm (v6.10+) dependencies:** ```yaml # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support # documentation. +# NOTE: pnpm caching support requires pnpm version >= 6.10.0 + steps: - uses: actions/checkout@v2 - uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2 with: - version: 6.9.0 + version: 6.10.0 - uses: actions/setup-node@v2 with: node-version: '14' diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 02e4fefb..2a0dfa54 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -4282,14 +4282,9 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const exec = __importStar(__webpack_require__(986)); -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); exports.supportedPackageManagers = { npm: { lockFilePatterns: ['package-lock.json', 'yarn.lock'], @@ -4297,8 +4292,7 @@ exports.supportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm get store', - defaultCacheFolder: path_1.default.join(os_1.default.homedir(), '.pnpm-store') + getCacheFolderCommand: 'pnpm store path' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -4345,14 +4339,7 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo } }); exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { - 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; - } + const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); if (!stdOut) { throw new Error(`Could not get cache folder path for ${packageManager}`); } diff --git a/dist/setup/index.js b/dist/setup/index.js index 07e6781f..1a213700 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -51580,14 +51580,9 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const exec = __importStar(__webpack_require__(986)); -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); exports.supportedPackageManagers = { npm: { lockFilePatterns: ['package-lock.json', 'yarn.lock'], @@ -51595,8 +51590,7 @@ exports.supportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm get store', - defaultCacheFolder: path_1.default.join(os_1.default.homedir(), '.pnpm-store') + getCacheFolderCommand: 'pnpm store path' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -51643,14 +51637,7 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo } }); exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () { - 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; - } + const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand); if (!stdOut) { throw new Error(`Could not get cache folder path for ${packageManager}`); } diff --git a/src/cache-utils.ts b/src/cache-utils.ts index f39fe8a2..774e87b3 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -10,7 +10,6 @@ type SupportedPackageManagers = { export interface PackageManagerInfo { lockFilePatterns: Array; getCacheFolderCommand: string; - defaultCacheFolder?: string; } export const supportedPackageManagers: SupportedPackageManagers = { @@ -20,8 +19,7 @@ export const supportedPackageManagers: SupportedPackageManagers = { }, pnpm: { lockFilePatterns: ['pnpm-lock.yaml'], - getCacheFolderCommand: 'pnpm get store', - defaultCacheFolder: path.join(os.homedir(), '.pnpm-store') + getCacheFolderCommand: 'pnpm store path' }, yarn1: { lockFilePatterns: ['yarn.lock'], @@ -80,16 +78,9 @@ export const getCacheDirectoryPath = async ( packageManagerInfo: PackageManagerInfo, packageManager: string ) => { - let stdOut = await getCommandOutput(packageManagerInfo.getCacheFolderCommand); - - // pnpm returns 'undefined' if no custom store path is set - if (stdOut === 'undefined') { - stdOut = ''; - } - - if (!stdOut && packageManagerInfo.defaultCacheFolder) { - stdOut = packageManagerInfo.defaultCacheFolder; - } + const stdOut = await getCommandOutput( + packageManagerInfo.getCacheFolderCommand + ); if (!stdOut) { throw new Error(`Could not get cache folder path for ${packageManager}`);