Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw on reading undefined file path #1

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

brendankenny
Copy link

Fixes building lighthouse in Node 15.

static-module calls brfs when it encounters a fs.readFileSync (and the other read methods) with a string file if the path can be statically determined or undefined if the path is too dynamic to figure out.

Previous to Node 15, when brfs then does fs.createReadStream(file), if file is undefined it would immediately throw, static-module would catch the error, and the original code would be retained instead of replacing it with an inline string.

Node 15 made a change to stream construction (nodejs/node#29656) that made stream construction lazier, and so the error comes later (when piping begins), static-module no longer catches the error, and everything fails instead of continuing.

This is probably the simplest fix, still throwing if file is undefined, just explicitly now instead of relying on fs.createReadStream throwing.

@wardpeet wardpeet merged commit b2d0464 into wardpeet:feat/transforms Nov 17, 2020
@brendankenny brendankenny deleted the patch-1 branch November 17, 2020 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants