Skip to content

Commit

Permalink
fix(isDirectory): handle non-existent relativePath
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescdavis committed Oct 22, 2020
1 parent 6710a71 commit 70f7fd2
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,22 @@ abstract class Filter extends Plugin {
return false;
}

return (entry || this.input.lstatSync(relativePath)).isDirectory();
if (entry !== undefined) {
return entry.isDirectory();
} else {
try {
// wrap this in try/catch in case `relativePath` doesn't exist
const stat = this.input.lstatSync(relativePath);
return stat.isDirectory();
} catch (error) {
// if we get any other error, we really don't know what is going on so we need to rethrow
if (error.code === 'ENOENT') {
return false;
}
throw error;
}
}
return entry ? entry.isDirectory() : this.input.existsSync(relativePath) && this.input.lstatSync(relativePath).isDirectory();
}

getDestFilePath(relativePath: string, entry: Entry) {
Expand Down

0 comments on commit 70f7fd2

Please sign in to comment.