mirror of
https://gitea.com/actions/setup-node.git
synced 2024-11-21 17:49:33 +01:00
Add check for existing paths (#803)
This commit is contained in:
parent
f8aa08ed8e
commit
34050076a5
3 changed files with 16 additions and 5 deletions
2
.github/workflows/e2e-cache.yml
vendored
2
.github/workflows/e2e-cache.yml
vendored
|
@ -173,7 +173,7 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: prepare sub-projects
|
- name: prepare sub-projects
|
||||||
run: __tests__/prepare-yarn-subprojects.sh
|
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
|
||||||
|
|
||||||
# expect
|
# expect
|
||||||
# - no errors
|
# - no errors
|
||||||
|
|
9
dist/cache-save/index.js
vendored
9
dist/cache-save/index.js
vendored
|
@ -60361,10 +60361,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
|
@ -60389,13 +60393,14 @@ exports.run = run;
|
||||||
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
const cachePackages = (packageManager) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
const state = core.getState(constants_1.State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||||
const cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
|
let cachePaths = JSON.parse(core.getState(constants_1.State.CachePaths) || '[]');
|
||||||
|
cachePaths = cachePaths.filter(fs_1.default.existsSync);
|
||||||
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
core.debug(`Caching for '${packageManager}' is not supported`);
|
core.debug(`Caching for '${packageManager}' is not supported`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cachePaths.length === 0) {
|
if (!cachePaths.length) {
|
||||||
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
||||||
// export declare function getInput(name: string, options?: InputOptions): string;
|
// export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as cache from '@actions/cache';
|
import * as cache from '@actions/cache';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
import {State} from './constants';
|
import {State} from './constants';
|
||||||
import {getPackageManagerInfo} from './cache-utils';
|
import {getPackageManagerInfo} from './cache-utils';
|
||||||
|
|
||||||
|
@ -23,7 +26,10 @@ export async function run() {
|
||||||
const cachePackages = async (packageManager: string) => {
|
const cachePackages = async (packageManager: string) => {
|
||||||
const state = core.getState(State.CacheMatchedKey);
|
const state = core.getState(State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(State.CachePrimaryKey);
|
const primaryKey = core.getState(State.CachePrimaryKey);
|
||||||
const cachePaths = JSON.parse(core.getState(State.CachePaths) || '[]');
|
let cachePaths = JSON.parse(
|
||||||
|
core.getState(State.CachePaths) || '[]'
|
||||||
|
) as string[];
|
||||||
|
cachePaths = cachePaths.filter(fs.existsSync);
|
||||||
|
|
||||||
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
const packageManagerInfo = await getPackageManagerInfo(packageManager);
|
||||||
if (!packageManagerInfo) {
|
if (!packageManagerInfo) {
|
||||||
|
@ -31,7 +37,7 @@ const cachePackages = async (packageManager: string) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cachePaths.length === 0) {
|
if (!cachePaths.length) {
|
||||||
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
// TODO: core.getInput has a bug - it can return undefined despite its definition (tests only?)
|
||||||
// export declare function getInput(name: string, options?: InputOptions): string;
|
// export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
const cacheDependencyPath = core.getInput('cache-dependency-path') || '';
|
||||||
|
|
Loading…
Reference in a new issue