Check if process.env.windir is defined #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
path.join will throw an error if undefined.
Even though platform is win32, process.env.windir may be undefined.
In this case the library should fallback to the path reg, one could add more fallback options like %systemroot%.
But falling back to path is definitly better than failing.
I came upon this issue using winreg in electron 29.1.1
TypeError: The "path" argument must be of type string. Received undefined at __node_internal_captureLargerStackTrace (node:internal/errors:497:5) at new NodeError (node:internal/errors:406:5) at validateString (node:internal/validators:162:11) at Object.join (node:path:433:7) at xs (index-2b4f9e2c.js:51:251) at ht.values (index-2b4f9e2c.js:51:1965) at ht.keyExists (index-2b4f9e2c.js:54:2663)
function xs() { return process.platform === "win32" ? a5.join({}.windir, "system32", "reg.exe") : "REG" }