Skip to content

Commit

Permalink
Update check for fs.stat/fs.lstat bigint support. (#171)
Browse files Browse the repository at this point in the history
* Update check for fs.stat/fs.lstat bigint support.

Fix:
#170

* Update index.js

* Update index.js

* Update index.js

Co-authored-by: Paul Miller <[email protected]>
  • Loading branch information
jmathew and paulmillr authored Feb 27, 2021
1 parent 62eea1a commit 6ffb4c6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const EVERYTHING_TYPE = 'all';
const ALL_TYPES = [FILE_TYPE, DIR_TYPE, FILE_DIR_TYPE, EVERYTHING_TYPE];

const isNormalFlowError = error => NORMAL_FLOW_ERRORS.has(error.code);
const [maj, min] = process.versions.node.split('.').slice(0, 2).map(n => Number.parseInt(n, 10));
const wantBigintFsStats = process.platform === 'win32' && (maj > 10 || (maj === 10 && min >= 5));

const normalizeFilter = filter => {
if (filter === undefined) return;
Expand Down Expand Up @@ -92,7 +94,7 @@ class ReaddirpStream extends Readable {

const statMethod = opts.lstat ? lstat : stat;
// Use bigint stats if it's windows and stat() supports options (node 10+).
if (process.platform === 'win32' && stat.length === 3) {
if (wantBigintFsStats) {
this._stat = path => statMethod(path, { bigint: true });
} else {
this._stat = statMethod;
Expand Down

0 comments on commit 6ffb4c6

Please sign in to comment.