Skip to content

Commit

Permalink
fix(export): provide a clear error when local snaps are missing (#6928)
Browse files Browse the repository at this point in the history
Currently, in this case it shows an obscure error: `TypeError: Cannot read properties of null (reading 'refsWithOptions')`. 
With this PR, it shows the standard VersionNotFound error, which outlines the component name and the missing snap.
  • Loading branch information
davidfirst authored Jan 17, 2023
1 parent 5f184bf commit 37b4180
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scope/models/model-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,10 @@ export default class Component extends BitObject {
);
const versionsRefs = versions.map((version) => this.getRef(version) as Ref);
refsWithoutArtifacts.push(...versionsRefs);
// @ts-ignore
const versionsObjects: Version[] = await Promise.all(versionsRefs.map((versionRef) => versionRef.load(repo)));

const versionsObjects: Version[] = await Promise.all(
versionsRefs.map((versionRef) => this.loadVersion(versionRef.toString(), repo))
);
versionsObjects.forEach((versionObject) => {
const refs = versionObject.refsWithOptions(false, false);
refsWithoutArtifacts.push(...refs);
Expand Down

0 comments on commit 37b4180

Please sign in to comment.