From d6ac7eb3e123e429af875af3c23c93c755f5ec0c Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 30 May 2022 13:25:36 +0530 Subject: [PATCH] Check for dependency directory before saving cache --- dist/index.js | 3 ++- src/cache.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 79b19e8..6f54b47 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35,6 +35,7 @@ const exec_1 = __nccwpck_require__(1514); const cache = __importStar(__nccwpck_require__(7799)); const core = __importStar(__nccwpck_require__(2186)); const spu = __importStar(__nccwpck_require__(2700)); +const fs = __importStar(__nccwpck_require__(7147)); const path = __importStar(__nccwpck_require__(1017)); const utils = __importStar(__nccwpck_require__(918)); 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_hit = await cache.restoreCache([cache_dir], cache_key, [cache_key]); await (0, exec_1.exec)(await utils.scriptCall('dependencies', extensions, version)); - if (!cache_hit) { + if (!cache_hit && fs.existsSync(cache_dir)) { try { await cache.saveCache([cache_dir], cache_key); } diff --git a/src/cache.ts b/src/cache.ts index 945ab45..e9973ce 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -2,6 +2,7 @@ import {exec} from '@actions/exec'; import * as cache from '@actions/cache'; import * as core from '@actions/core'; import * as spu from 'setup-php/lib/utils'; +import * as fs from 'fs'; import * as path from 'path'; import * as utils from './utils'; @@ -27,7 +28,7 @@ export async function handleDependencies( [cache_key] ); await exec(await utils.scriptCall('dependencies', extensions, version)); - if (!cache_hit) { + if (!cache_hit && fs.existsSync(cache_dir)) { try { await cache.saveCache([cache_dir], cache_key); } catch {