Skip to content

Commit

Permalink
fix: πŸ› refactor #openFile to be compatible w/ strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Jul 6, 2019
1 parent e9ba56c commit 1c4a4ba
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/volume.ts
Expand Up @@ -923,14 +923,19 @@ export class Volume {
return file;
}

private openFile(filename: string, flagsNum: number, modeNum: number, resolveSymlinks: boolean = true): File {
private openFile(
filename: string,
flagsNum: number,
modeNum: number | undefined,
resolveSymlinks: boolean = true,
): File {
const steps = filenameToSteps(filename);
let link: Link = resolveSymlinks ? this.getResolvedLink(steps) : this.getLink(steps);
let link: Link | null = resolveSymlinks ? this.getResolvedLink(steps) : this.getLink(steps);

// Try creating a new file, if it does not exist.
if (!link && flagsNum & O_CREAT) {
// const dirLink: Link = this.getLinkParent(steps);
const dirLink: Link = this.getResolvedLink(steps.slice(0, steps.length - 1));
const dirLink: Link | null = this.getResolvedLink(steps.slice(0, steps.length - 1));
// if(!dirLink) throw createError(ENOENT, 'open', filename);
if (!dirLink) throw createError(ENOENT, 'open', sep + steps.join(sep));

Expand Down

0 comments on commit 1c4a4ba

Please sign in to comment.