mirror of
https://github.com/actions/setup-go.git
synced 2025-04-23 17:40:50 +00:00
refactor getCacheDirectoryPath to utilize side-effect of map
This commit is contained in:
parent
c09fdc8076
commit
4e2636afea
3 changed files with 30 additions and 30 deletions
17
dist/cache-save/index.js
vendored
17
dist/cache-save/index.js
vendored
|
@ -60458,13 +60458,16 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
||||||
pathOutputs
|
const results = pathOutputs.map(item => {
|
||||||
.filter(output => output.status === 'rejected')
|
if (item.status === 'fulfilled') {
|
||||||
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
|
return item.value;
|
||||||
const cachePaths = pathOutputs
|
}
|
||||||
.filter(output => output.status === 'fulfilled' &&
|
else {
|
||||||
output.value)
|
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
|
||||||
.map(output => output.value);
|
}
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
const cachePaths = results.filter(item => item);
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
|
|
17
dist/setup/index.js
vendored
17
dist/setup/index.js
vendored
|
@ -63131,13 +63131,16 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
const pathOutputs = yield Promise.allSettled(packageManagerInfo.cacheFolderCommandList.map((command) => __awaiter(void 0, void 0, void 0, function* () { return exports.getCommandOutput(command); })));
|
||||||
pathOutputs
|
const results = pathOutputs.map(item => {
|
||||||
.filter(output => output.status === 'rejected')
|
if (item.status === 'fulfilled') {
|
||||||
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
|
return item.value;
|
||||||
const cachePaths = pathOutputs
|
}
|
||||||
.filter(output => output.status === 'fulfilled' &&
|
else {
|
||||||
output.value)
|
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
|
||||||
.map(output => output.value);
|
}
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
const cachePaths = results.filter(item => item);
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,23 +40,17 @@ export const getCacheDirectoryPath = async (
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
pathOutputs
|
const results = pathOutputs.map(item => {
|
||||||
.filter(output => output.status === 'rejected')
|
if (item.status === 'fulfilled') {
|
||||||
.forEach(output =>
|
return item.value;
|
||||||
core.warning(
|
} else {
|
||||||
`getting cache directory path failed: ${
|
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
|
||||||
(output as PromiseRejectedResult).reason
|
}
|
||||||
}`
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const cachePaths = pathOutputs
|
return '';
|
||||||
.filter(
|
});
|
||||||
output =>
|
|
||||||
output.status === 'fulfilled' &&
|
const cachePaths = results.filter(item => item);
|
||||||
(output as PromiseFulfilledResult<string>).value
|
|
||||||
)
|
|
||||||
.map(output => (output as PromiseFulfilledResult<string>).value);
|
|
||||||
|
|
||||||
if (!cachePaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue