Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
encoding: close file handle (#2958)
Browse files Browse the repository at this point in the history
[bugfix] `encoding` closes files correctly
Fixes: #2954
  • Loading branch information
ajafff authored and adidahiya committed Jul 5, 2017
1 parent 4e8474f commit 3f5a7bd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/rules/encodingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ function detectEncoding(fileName: string): Encoding {
const maxBytesRead = 3; // Only need 3 bytes to detect the encoding.
const buffer = new Buffer(maxBytesRead);
const bytesRead = fs.readSync(fd, buffer, /*offset*/ 0, /*length*/ maxBytesRead, /*position*/ 0);
fs.closeSync(fd);
return detectBufferEncoding(buffer, bytesRead);
}

0 comments on commit 3f5a7bd

Please sign in to comment.