Skip to content

Commit

Permalink
Fix yarn es snapshot cache hit (#161183)
Browse files Browse the repository at this point in the history
The `yarn es` command provides a useful `--use-cached` to avoid
redownloading the cache, but this is always skipped because no one set
the `exists` field is required by the command to check if the cache is
available.

This commit just adds that `exists` property where is needed (when reading
the `.meta` file) and leaves the rest of the code unaltered.
I could have implemented the same behavior by returning `null` from the
`readMeta` and doing a null check where we checked for the `exists`
property. Please feel free which approach you feel better.
  • Loading branch information
markov00 authored Jul 6, 2023
1 parent 060cc5b commit acba5fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/kbn-es/src/utils/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ export const cache = {

return {
...JSON.parse(meta),
exists: true,
};
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}

return {};
return {
exists: false,
};
}
},

Expand Down

0 comments on commit acba5fb

Please sign in to comment.