Check for dependency directory before saving cache

This commit is contained in:
Shivam Mathur
2022-05-30 13:25:36 +05:30
parent 845ca860fc
commit d6ac7eb3e1
2 changed files with 4 additions and 2 deletions

3
dist/index.js vendored
View File

@@ -35,6 +35,7 @@ const exec_1 = __nccwpck_require__(1514);
const cache = __importStar(__nccwpck_require__(7799)); const cache = __importStar(__nccwpck_require__(7799));
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const spu = __importStar(__nccwpck_require__(2700)); const spu = __importStar(__nccwpck_require__(2700));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017)); const path = __importStar(__nccwpck_require__(1017));
const utils = __importStar(__nccwpck_require__(918)); const utils = __importStar(__nccwpck_require__(918));
async function handleDependencies(extensions, version) { async function handleDependencies(extensions, version) {
@@ -43,7 +44,7 @@ async function handleDependencies(extensions, version) {
const cache_dir = path.join(await spu.readEnv('RUNNER_TOOL_CACHE'), 'deps'); const cache_dir = path.join(await spu.readEnv('RUNNER_TOOL_CACHE'), 'deps');
const cache_hit = await cache.restoreCache([cache_dir], cache_key, [cache_key]); const cache_hit = await cache.restoreCache([cache_dir], cache_key, [cache_key]);
await (0, exec_1.exec)(await utils.scriptCall('dependencies', extensions, version)); await (0, exec_1.exec)(await utils.scriptCall('dependencies', extensions, version));
if (!cache_hit) { if (!cache_hit && fs.existsSync(cache_dir)) {
try { try {
await cache.saveCache([cache_dir], cache_key); await cache.saveCache([cache_dir], cache_key);
} }

View File

@@ -2,6 +2,7 @@ import {exec} from '@actions/exec';
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as spu from 'setup-php/lib/utils'; import * as spu from 'setup-php/lib/utils';
import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as utils from './utils'; import * as utils from './utils';
@@ -27,7 +28,7 @@ export async function handleDependencies(
[cache_key] [cache_key]
); );
await exec(await utils.scriptCall('dependencies', extensions, version)); await exec(await utils.scriptCall('dependencies', extensions, version));
if (!cache_hit) { if (!cache_hit && fs.existsSync(cache_dir)) {
try { try {
await cache.saveCache([cache_dir], cache_key); await cache.saveCache([cache_dir], cache_key);
} catch { } catch {