fix(core): provide more info for "findOriginalKeys is not a function" errors (#16883)

This commit is contained in:
Miroslav Jonaš 2023-05-10 17:41:49 +02:00 committed by GitHub
parent e481cd5461
commit d26f26a98b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -285,7 +285,13 @@ function mapSnapshots(
// collect snapshots and their matching keys
Object.values(nodes).forEach((node) => {
const [matchedKeys, snapshot] = findOriginalKeys(groupedDependencies, node);
const foundOriginalKeys = findOriginalKeys(groupedDependencies, node);
if (!foundOriginalKeys) {
throw new Error(
`Original key(s) not found for "${node.data.packageName}@${node.data.version}" while pruning yarn.lock.`
);
}
const [matchedKeys, snapshot] = foundOriginalKeys;
snapshotMap.set(snapshot, new Set(matchedKeys));
// separately save keys that still exist