You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means the return value may describe a file or a directory; consumers must determine which before they can use it safely. Because this behavior is undocumented, I first guessed this was an oversight. However, there is an explicit test for it:
it('should default to process.cwd() if require.main is undefined',function(){requireMainFilename({}).should.match(/require-main-filename/)})
Can any of the maintainers explain the rationale for this behavior? And since it differs from the Node.js feature that this module is intended to mimic, can that be added to the project documentation?
I'm also curious if the function signature could be extended with an "options" object to enable "strict" behavior, where undefined is returned in cases where the main module is undefined.
The text was updated successfully, but these errors were encountered:
@jugglinmike sorry for ignoring this for so long; I don't honestly remember the original reasoning for falling back to process.cwd. We're getting close to retiring require-main-filename for some contexts in yargs, via yargs/yargs#1262.
I also wonder will main.filename ever not be set in Node>6? I wonder what edge-case we were protecting against here.
As of version 1.0.2, this module returns the current working directory when the "main" module cannot be identified:
This means the return value may describe a file or a directory; consumers must determine which before they can use it safely. Because this behavior is undocumented, I first guessed this was an oversight. However, there is an explicit test for it:
Can any of the maintainers explain the rationale for this behavior? And since it differs from the Node.js feature that this module is intended to mimic, can that be added to the project documentation?
I'm also curious if the function signature could be extended with an "options" object to enable "strict" behavior, where
undefined
is returned in cases where themain
module is undefined.The text was updated successfully, but these errors were encountered: