Skip to content

Commit

Permalink
fix: πŸ› create tryGetChild util function
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jul 13, 2019
1 parent 4b7f164 commit b5093a1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/__tests__/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ export const createFs = (json?) => {
return createFsFromVolume(create(json));
};

export const tryGetChildNode = (link: Link, name: string): Node => {
export const tryGetChild = (link: Link, name: string): Link => {
const child = link.getChild(name);

if (!child) {
throw new Error(`expected link to have a child named "${name}"`);
}

return child.getNode();
return child;
};

export const tryGetChildNode = (link: Link, name: string): Node => tryGetChild(link, name).getNode();

0 comments on commit b5093a1

Please sign in to comment.