Skip to content

Commit

Permalink
fix: πŸ› refactor #createLink to be compatible w/ strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jul 11, 2019
1 parent b396f04 commit 7d8559d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/volume.ts
Expand Up @@ -618,7 +618,15 @@ export class Volume {
createLink(): Link;
createLink(parent: Link, name: string, isDirectory?: boolean, perm?: number): Link;
createLink(parent?: Link, name?: string, isDirectory: boolean = false, perm?: number): Link {
return parent ? parent.createChild(name, this.createNode(isDirectory, perm)) : new this.props.Link(this, null, '');
if (!parent) {
return new this.props.Link(this, null, '');
}

if (!name) {
throw new Error('createLink: name cannot be empty');
}

return parent.createChild(name, this.createNode(isDirectory, perm));
}

deleteLink(link: Link): boolean {
Expand Down

0 comments on commit 7d8559d

Please sign in to comment.