From e8afe8a475497eea77cb495c3ed0dd15cad291a8 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 15 Sep 2021 00:07:18 +0300 Subject: [PATCH] fix path --- dist/cache-save/index.js | 16 +++++++++++----- dist/setup/index.js | 2 +- src/cache-distributions/cache-distributor.ts | 2 +- src/cache-save.ts | 13 +++++++++---- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 7177ef81..acfe0d69 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -35064,7 +35064,7 @@ class CacheDistributor { isCacheDirectoryExists(cacheDirectory) { const result = cacheDirectory.reduce((previousValue, currentValue) => { const resolvePath = currentValue.includes('~') - ? path.join(currentValue.slice(1), os.homedir()) + ? path.join(os.homedir(), currentValue.slice(1)) : currentValue; return previousValue || fs.existsSync(resolvePath); }, false); @@ -46564,10 +46564,16 @@ const core = __importStar(__webpack_require__(470)); const cache_factory_1 = __webpack_require__(633); function cacheSave() { return __awaiter(this, void 0, void 0, function* () { - const cache = core.getInput('cache'); - if (cache) { - const cacheManager = cache_factory_1.getCache(cache, ''); - cacheManager.saveCache(); + try { + const cache = core.getInput('cache'); + if (cache) { + const cacheManager = cache_factory_1.getCache(cache, ''); + cacheManager.saveCache(); + } + } + catch (error) { + const err = error; + core.setFailed(err.message); } }); } diff --git a/dist/setup/index.js b/dist/setup/index.js index 295d10a6..3ef668f7 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -36833,7 +36833,7 @@ class CacheDistributor { isCacheDirectoryExists(cacheDirectory) { const result = cacheDirectory.reduce((previousValue, currentValue) => { const resolvePath = currentValue.includes('~') - ? path.join(currentValue.slice(1), os.homedir()) + ? path.join(os.homedir(), currentValue.slice(1)) : currentValue; return previousValue || fs.existsSync(resolvePath); }, false); diff --git a/src/cache-distributions/cache-distributor.ts b/src/cache-distributions/cache-distributor.ts index e9b4c2e4..9a6e956d 100644 --- a/src/cache-distributions/cache-distributor.ts +++ b/src/cache-distributions/cache-distributor.ts @@ -40,7 +40,7 @@ abstract class CacheDistributor { protected isCacheDirectoryExists(cacheDirectory: string[]) { const result = cacheDirectory.reduce((previousValue, currentValue) => { const resolvePath = currentValue.includes('~') - ? path.join(currentValue.slice(1), os.homedir()) + ? path.join(os.homedir(), currentValue.slice(1)) : currentValue; return previousValue || fs.existsSync(resolvePath); }, false); diff --git a/src/cache-save.ts b/src/cache-save.ts index b1afeba8..f6ceef88 100644 --- a/src/cache-save.ts +++ b/src/cache-save.ts @@ -2,10 +2,15 @@ import * as core from '@actions/core'; import {getCache} from './cache-distributions/cache-factory'; export async function cacheSave() { - const cache = core.getInput('cache'); - if (cache) { - const cacheManager = getCache(cache, ''); - cacheManager.saveCache(); + try { + const cache = core.getInput('cache'); + if (cache) { + const cacheManager = getCache(cache, ''); + cacheManager.saveCache(); + } + } catch (error) { + const err = error as Error; + core.setFailed(err.message); } }