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

Check if process.env.windir is defined #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kaibu
Copy link

@Kaibu Kaibu commented Apr 6, 2024

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" }

path.join will throw an error if undefined, even though platform is win32, process.env.windir may be undefined.
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.

1 participant