This PR prevents open from crashing when the package is bundled for non-ESM format.
It does so by adding a simple truthy guard for import.meta.url before passing it to fileURLToPath() function.
And since fileURLToPath() does not accept undefined value as argument, it will throw the following error:
node:internal/url:1210
throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of URL. Received undefined
...
This PR prevents
open
from crashing when the package is bundled for non-ESM format. It does so by adding a simple truthy guard forimport.meta.url
before passing it tofileURLToPath()
function.In non-ESM context,
import.meta.url
isundefined
. https://github.com/sindresorhus/open/blob/36c61af1e696ef4365fd12dcc733586877106f19/index.js#L13-L15And since
fileURLToPath()
does not acceptundefined
value as argument, it will throw the following error: