Change behavior of the exception throwing

This commit is contained in:
Ivan Zosimov 2022-04-20 16:43:06 +02:00
parent c64d0e04b0
commit 8c8442b8f8
5 changed files with 52 additions and 37 deletions

View file

@ -1,6 +1,7 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import path from 'path';
import {supportedPackageManagers, PackageManagerInfo} from './package-managers';
export const getCommandOutput = async (toolCommand: string) => {
@ -34,16 +35,16 @@ export const getPackageManagerInfo = async (packageManager: string) => {
export const getCacheDirectoryPath = async (
packageManagerInfo: PackageManagerInfo
) => {
let pathList: string[] = [];
let pathList = await Promise.all(
packageManagerInfo.cacheFolderCommandList.map(async command =>
getCommandOutput(command)
)
);
for (let command of packageManagerInfo.cacheFolderCommandList) {
pathList.push(await getCommandOutput(command));
}
const emptyPaths = pathList.filter(item => !item);
for (let path of pathList) {
if (!path) {
throw new Error(`Could not get cache folder paths.`);
}
if (emptyPaths.length) {
throw new Error(`Could not get cache folder paths.`);
}
return pathList;