Skip to content

throw on reading undefined file path - #1

Merged
wardpeet merged 1 commit into
wardpeet:feat/transformsfrom
brendankenny:patch-1
Nov 17, 2020
Merged

throw on reading undefined file path#1
wardpeet merged 1 commit into
wardpeet:feat/transformsfrom
brendankenny:patch-1

Conversation

@brendankenny

Copy link
Copy Markdown

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