readdirp
Advanced tools
Comparing version 3.5.0 to 3.6.0
17
index.js
@@ -24,3 +24,4 @@ 'use strict'; | ||
const BANG = '!'; | ||
const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP']); | ||
const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR'; | ||
const NORMAL_FLOW_ERRORS = new Set(['ENOENT', 'EPERM', 'EACCES', 'ELOOP', RECURSIVE_ERROR_CODE]); | ||
const FILE_TYPE = 'files'; | ||
@@ -33,2 +34,4 @@ const DIR_TYPE = 'directories'; | ||
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)); | ||
@@ -96,3 +99,3 @@ const normalizeFilter = filter => { | ||
// 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 }); | ||
@@ -172,3 +175,3 @@ } else { | ||
} | ||
return {files, depth, path}; | ||
return { files, depth, path }; | ||
} | ||
@@ -181,3 +184,3 @@ | ||
const fullPath = sysPath.resolve(sysPath.join(path, basename)); | ||
entry = {path: sysPath.relative(this._root, fullPath), fullPath, basename}; | ||
entry = { path: sysPath.relative(this._root, fullPath), fullPath, basename }; | ||
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath); | ||
@@ -222,5 +225,7 @@ } catch (err) { | ||
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sysPath.sep) { | ||
return this._onError(new Error( | ||
const recursiveError = new Error( | ||
`Circular symlink detected: "${full}" points to "${entryRealPath}"` | ||
)); | ||
); | ||
recursiveError.code = RECURSIVE_ERROR_CODE; | ||
return this._onError(recursiveError); | ||
} | ||
@@ -227,0 +232,0 @@ return 'directory'; |
{ | ||
"name": "readdirp", | ||
"description": "Recursive version of fs.readdir with streaming API.", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"homepage": "https://github.com/paulmillr/readdirp", | ||
@@ -6,0 +6,0 @@ "repository": { |
20472
290