Skip to content

Commit 3af302a

Browse files
Switch to pnpm store path command
1 parent f452812 commit 3af302a

File tree

4 files changed

+12
-45
lines changed

4 files changed

+12
-45
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,20 @@ steps:
5555
- run: npm test
5656
```
5757

58-
**Caching pnpm dependencies:**
58+
**Caching pnpm (v6.10+) dependencies:**
5959
```yaml
6060
# This workflow uses actions that are not certified by GitHub.
6161
# They are provided by a third-party and are governed by
6262
# separate terms of service, privacy policy, and support
6363
# documentation.
6464
65+
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
66+
6567
steps:
6668
- uses: actions/checkout@v2
6769
- uses: pnpm/action-setup@646cdf48217256a3d0b80361c5a50727664284f2
6870
with:
69-
version: 6.9.0
71+
version: 6.10.0
7072
- uses: actions/setup-node@v2
7173
with:
7274
node-version: '14'

dist/cache-save/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4282,23 +4282,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
42824282
result["default"] = mod;
42834283
return result;
42844284
};
4285-
var __importDefault = (this && this.__importDefault) || function (mod) {
4286-
return (mod && mod.__esModule) ? mod : { "default": mod };
4287-
};
42884285
Object.defineProperty(exports, "__esModule", { value: true });
42894286
const core = __importStar(__webpack_require__(470));
42904287
const exec = __importStar(__webpack_require__(986));
4291-
const os_1 = __importDefault(__webpack_require__(87));
4292-
const path_1 = __importDefault(__webpack_require__(622));
42934288
exports.supportedPackageManagers = {
42944289
npm: {
42954290
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
42964291
getCacheFolderCommand: 'npm config get cache'
42974292
},
42984293
pnpm: {
42994294
lockFilePatterns: ['pnpm-lock.yaml'],
4300-
getCacheFolderCommand: 'pnpm get store',
4301-
defaultCacheFolder: path_1.default.join(os_1.default.homedir(), '.pnpm-store')
4295+
getCacheFolderCommand: 'pnpm store path'
43024296
},
43034297
yarn1: {
43044298
lockFilePatterns: ['yarn.lock'],
@@ -4345,14 +4339,7 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo
43454339
}
43464340
});
43474341
exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
4348-
let stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
4349-
// pnpm returns 'undefined' if no custom store path is set
4350-
if (stdOut === 'undefined') {
4351-
stdOut = '';
4352-
}
4353-
if (!stdOut && packageManagerInfo.defaultCacheFolder) {
4354-
stdOut = packageManagerInfo.defaultCacheFolder;
4355-
}
4342+
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
43564343
if (!stdOut) {
43574344
throw new Error(`Could not get cache folder path for ${packageManager}`);
43584345
}

dist/setup/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51580,23 +51580,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
5158051580
result["default"] = mod;
5158151581
return result;
5158251582
};
51583-
var __importDefault = (this && this.__importDefault) || function (mod) {
51584-
return (mod && mod.__esModule) ? mod : { "default": mod };
51585-
};
5158651583
Object.defineProperty(exports, "__esModule", { value: true });
5158751584
const core = __importStar(__webpack_require__(470));
5158851585
const exec = __importStar(__webpack_require__(986));
51589-
const os_1 = __importDefault(__webpack_require__(87));
51590-
const path_1 = __importDefault(__webpack_require__(622));
5159151586
exports.supportedPackageManagers = {
5159251587
npm: {
5159351588
lockFilePatterns: ['package-lock.json', 'yarn.lock'],
5159451589
getCacheFolderCommand: 'npm config get cache'
5159551590
},
5159651591
pnpm: {
5159751592
lockFilePatterns: ['pnpm-lock.yaml'],
51598-
getCacheFolderCommand: 'pnpm get store',
51599-
defaultCacheFolder: path_1.default.join(os_1.default.homedir(), '.pnpm-store')
51593+
getCacheFolderCommand: 'pnpm store path'
5160051594
},
5160151595
yarn1: {
5160251596
lockFilePatterns: ['yarn.lock'],
@@ -51643,14 +51637,7 @@ exports.getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, vo
5164351637
}
5164451638
});
5164551639
exports.getCacheDirectoryPath = (packageManagerInfo, packageManager) => __awaiter(void 0, void 0, void 0, function* () {
51646-
let stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
51647-
// pnpm returns 'undefined' if no custom store path is set
51648-
if (stdOut === 'undefined') {
51649-
stdOut = '';
51650-
}
51651-
if (!stdOut && packageManagerInfo.defaultCacheFolder) {
51652-
stdOut = packageManagerInfo.defaultCacheFolder;
51653-
}
51640+
const stdOut = yield exports.getCommandOutput(packageManagerInfo.getCacheFolderCommand);
5165451641
if (!stdOut) {
5165551642
throw new Error(`Could not get cache folder path for ${packageManager}`);
5165651643
}

src/cache-utils.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ type SupportedPackageManagers = {
1010
export interface PackageManagerInfo {
1111
lockFilePatterns: Array<string>;
1212
getCacheFolderCommand: string;
13-
defaultCacheFolder?: string;
1413
}
1514

1615
export const supportedPackageManagers: SupportedPackageManagers = {
@@ -20,8 +19,7 @@ export const supportedPackageManagers: SupportedPackageManagers = {
2019
},
2120
pnpm: {
2221
lockFilePatterns: ['pnpm-lock.yaml'],
23-
getCacheFolderCommand: 'pnpm get store',
24-
defaultCacheFolder: path.join(os.homedir(), '.pnpm-store')
22+
getCacheFolderCommand: 'pnpm store path'
2523
},
2624
yarn1: {
2725
lockFilePatterns: ['yarn.lock'],
@@ -80,16 +78,9 @@ export const getCacheDirectoryPath = async (
8078
packageManagerInfo: PackageManagerInfo,
8179
packageManager: string
8280
) => {
83-
let stdOut = await getCommandOutput(packageManagerInfo.getCacheFolderCommand);
84-
85-
// pnpm returns 'undefined' if no custom store path is set
86-
if (stdOut === 'undefined') {
87-
stdOut = '';
88-
}
89-
90-
if (!stdOut && packageManagerInfo.defaultCacheFolder) {
91-
stdOut = packageManagerInfo.defaultCacheFolder;
92-
}
81+
const stdOut = await getCommandOutput(
82+
packageManagerInfo.getCacheFolderCommand
83+
);
9384

9485
if (!stdOut) {
9586
throw new Error(`Could not get cache folder path for ${packageManager}`);

0 commit comments

Comments
 (0)