Repository navigation
fix: close the file descriptor when reading a shebang fails - #187
Merged
Merged
Conversation
Unit tests live next to the code they test as `lib/**/*.test.js`, while `test/` keeps the end-to-end tests. Test files are excluded from the npm package and from coverage, and are linted with the same config as `test/`. ESLint 5 doesn't support `extends` in `overrides`, so the config moves to .eslintrc.js, extends the jest addon (which only applies to test files) and applies what es9 adds on top of es6 to `lib/**/*.test.js`.
readShebang only closed the file descriptor after a successful read, so it leaked when fs.readSync threw, e.g.: when the file is a directory. Based on #184. Co-authored-by: Huanyi Xie <74809554+xiehuanyi@users.noreply.github.com>
satazor
force-pushed
the
fix/shebang-close-descriptor
branch
from
November 1, 2026 16:28
90c4ff9 to
bd535d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
readShebangonly closed the file descriptor after a successful read, so it leaked whenfs.readSyncthrew, e.g.: when the file is a directory. The descriptor is now closed in afinallyblock, and a failure to close it keeps the existingnullfallback.This is based on #184 by @xiehuanyi, who is credited as co-author of the fix. Thank you!
This also adds support for unit tests next to the code they test, as
lib/**/*.test.js, whiletest/keeps the end-to-end tests:"!lib/**/*.test.js"infiles) and from coverage.test/(es9,nodeandjest). ESLint 5 doesn't supportextendsinoverrides, so.eslintrcbecame.eslintrc.js, which extends the moxy jest addon (it only applies to test files) and applies whates9adds on top ofes6tolib/**/*.test.js.eslint --print-configconfirms thatlib/**/*.test.jsandtest/**/*.test.jsnow get the same effective config.Supersedes #184.