Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable caching by default with default input #332

Merged
merged 8 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor getCacheDirectoryPath to utilize side-effect of map
  • Loading branch information
dsame committed Mar 10, 2023
commit 4e2636afea7faca4d3bb7c8f931d0def2a029299
17 changes: 10 additions & 7 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60458,13 +60458,16 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
exports.getPackageManagerInfo = getPackageManagerInfo;
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); })));
pathOutputs
.filter(output => output.status === 'rejected')
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
const cachePaths = pathOutputs
.filter(output => output.status === 'fulfilled' &&
output.value)
.map(output => output.value);
const results = pathOutputs.map(item => {
if (item.status === 'fulfilled') {
return item.value;
}
else {
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
}
return '';
});
const cachePaths = results.filter(item => item);
if (!cachePaths.length) {
throw new Error(`Could not get cache folder paths.`);
}
Expand Down
17 changes: 10 additions & 7 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63131,13 +63131,16 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
exports.getPackageManagerInfo = getPackageManagerInfo;
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); })));
pathOutputs
.filter(output => output.status === 'rejected')
.forEach(output => core.warning(`getting cache directory path failed: ${output.reason}`));
const cachePaths = pathOutputs
.filter(output => output.status === 'fulfilled' &&
output.value)
.map(output => output.value);
const results = pathOutputs.map(item => {
if (item.status === 'fulfilled') {
return item.value;
}
else {
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
}
return '';
});
const cachePaths = results.filter(item => item);
if (!cachePaths.length) {
throw new Error(`Could not get cache folder paths.`);
}
Expand Down
26 changes: 10 additions & 16 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,17 @@ export const getCacheDirectoryPath = async (
)
);

pathOutputs
.filter(output => output.status === 'rejected')
.forEach(output =>
core.warning(
`getting cache directory path failed: ${
(output as PromiseRejectedResult).reason
}`
)
);
const results = pathOutputs.map(item => {
if (item.status === 'fulfilled') {
return item.value;
} else {
core.info(`[warning]getting cache directory path failed: ${item.reason}`);
}

const cachePaths = pathOutputs
.filter(
output =>
output.status === 'fulfilled' &&
(output as PromiseFulfilledResult<string>).value
)
.map(output => (output as PromiseFulfilledResult<string>).value);
return '';
});

const cachePaths = results.filter(item => item);

if (!cachePaths.length) {
throw new Error(`Could not get cache folder paths.`);
Expand Down