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.
I'm bundling term-size using esbuild, which handles
import.meta.url
a bit differently than other bundlers.Now, in my case, the
fileURLToPath
call is dead code, because I'm running my bundle on Linux, where term-size doesn't need to invoke any commands. So I was thinking it could be more lazy, and coincidentally fix the issue I'm facing.This PR moves the
__dirname
emulation into a helper function that's only called on macOS and Windows.I've also put the line-splitting in there because I prefer DRY code, but it's a bit esoteric this way. Would you prefer an explicit
splitLines
(or even a dependency onsplit-lines
)? Or alternatively, I could make a less invasive PR and only extract the__dirname
construction into a helper function, for example.... Or we could find a better way to deal with the lack of
__dirname
in ESM. 😉