Skip to content

Commit

Permalink
introduce a new API "getCurrentSnap()" for the Component object (#8677)
Browse files Browse the repository at this point in the history
It was requested a while ago by Ran/Guy.
  • Loading branch information
davidfirst authored Mar 18, 2024
1 parent 331269f commit 2d03f04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scopes/component/component/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,16 @@ export class Component implements IComponent {
return this.id.version;
}

/**
* in case a component is new, it returns undefined.
* otherwise, it returns the Snap object (hash/parents/log) of the current component (according to the version in the id)
*/
async getCurrentSnap(): Promise<Snap | undefined> {
const snap = this.getSnapHash();
if (!snap) return undefined;
return this.loadSnap(snap);
}

/**
* checkout the component to a different version in its working tree.
*/
Expand Down

0 comments on commit 2d03f04

Please sign in to comment.