Comparing version 8.1.1 to 8.2.0
65
index.js
@@ -70,14 +70,21 @@ "use strict"; | ||
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink(); | ||
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path); | ||
let stats; | ||
if (opts.stats) { | ||
try { | ||
stats = await (opts.followSymlinks ? stat : lstat)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
yield {path, err}; | ||
if (isIncluded) { | ||
if (opts.stats || isSymbolicLink) { | ||
try { | ||
stats = await (opts.followSymlinks ? stat : lstat)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
yield {path, err}; | ||
} | ||
} | ||
yield build(dirent, path, stats, opts); | ||
} | ||
let recurse = false; | ||
if (opts.followSymlinks && dirent.isSymbolicLink()) { | ||
if (isSymbolicLink) { | ||
if (!stats) try { stats = await stat(path); } catch {} | ||
@@ -89,3 +96,2 @@ if (stats && stats.isDirectory()) recurse = true; | ||
if (!includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path)) yield build(dirent, path, stats, opts); | ||
if (recurse) yield* await rrdir(path, opts, {includeMatcher, excludeMatcher, encoding}); | ||
@@ -121,14 +127,21 @@ } | ||
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink(); | ||
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path); | ||
let stats; | ||
if (opts.stats) { | ||
try { | ||
stats = await (opts.followSymlinks ? stat : lstat)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
results.push({path, err}); | ||
if (isIncluded) { | ||
if (opts.stats || isSymbolicLink) { | ||
try { | ||
stats = await (opts.followSymlinks ? stat : lstat)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
results.push({path, err}); | ||
} | ||
} | ||
results.push(build(dirent, path, stats, opts)); | ||
} | ||
let recurse = false; | ||
if (opts.followSymlinks && dirent.isSymbolicLink()) { | ||
if (isSymbolicLink) { | ||
if (!stats) try { stats = await stat(path); } catch {} | ||
@@ -140,3 +153,2 @@ if (stats && stats.isDirectory()) recurse = true; | ||
if (!includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path)) results.push(build(dirent, path, stats, opts)); | ||
if (recurse) results.push(...await module.exports.async(path, opts, {includeMatcher, excludeMatcher, encoding})); | ||
@@ -174,14 +186,20 @@ })); | ||
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink(); | ||
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path); | ||
let stats; | ||
if (opts.stats) { | ||
try { | ||
stats = (opts.followSymlinks ? statSync : lstatSync)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
results.push({path, err}); | ||
if (isIncluded) { | ||
if (opts.stats || isSymbolicLink) { | ||
try { | ||
stats = (opts.followSymlinks ? statSync : lstatSync)(path); | ||
} catch (err) { | ||
if (opts.strict) throw err; | ||
results.push({path, err}); | ||
} | ||
} | ||
results.push(build(dirent, path, stats, opts)); | ||
} | ||
let recurse = false; | ||
if (opts.followSymlinks && dirent.isSymbolicLink()) { | ||
if (isSymbolicLink) { | ||
if (!stats) try { stats = statSync(path); } catch {} | ||
@@ -193,3 +211,2 @@ if (stats && stats.isDirectory()) recurse = true; | ||
if (!includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path)) results.push(build(dirent, path, stats, opts)); | ||
if (recurse) results.push(...module.exports.sync(path, opts, {includeMatcher, excludeMatcher, encoding})); | ||
@@ -196,0 +213,0 @@ } |
{ | ||
"name": "rrdir", | ||
"version": "8.1.1", | ||
"version": "8.2.0", | ||
"description": "Recursive directory reader with a delightful API", | ||
@@ -22,10 +22,10 @@ "author": "silverwind <me@silverwind.io>", | ||
"devDependencies": { | ||
"del": "5.1.0", | ||
"eslint": "7.0.0", | ||
"eslint-config-silverwind": "13.3.3", | ||
"jest": "26.0.1", | ||
"del": "6.0.0", | ||
"eslint": "7.11.0", | ||
"eslint-config-silverwind": "21.0.0", | ||
"jest": "26.5.3", | ||
"semver": "7.3.2", | ||
"tempy": "0.5.0", | ||
"updates": "10.2.12", | ||
"versions": "8.2.10" | ||
"tempy": "1.0.0", | ||
"updates": "11.2.5", | ||
"versions": "8.4.3" | ||
}, | ||
@@ -32,0 +32,0 @@ "keywords": [ |
@@ -36,3 +36,3 @@ # rrdir | ||
The directory to read. | ||
The directory to read, either absolute or relative. Pass a `Buffer` to switch the module into `Buffer` mode which is required to be able to read every file, like for example files with names that are invalid UTF-8 sequences. | ||
@@ -50,3 +50,3 @@ #### `options` *Object* | ||
- `path` *string* | *Buffer*: The path to the entry, will be relative if `dir` is given relative. If `dir` is a Buffer, this will be too. Always present. | ||
- `path` *string* | *Buffer*: The path to the entry, will be relative if `dir` is given relative. If `dir` is a `Buffer`, this will be too. Always present. | ||
- `directory` *boolean*: Boolean indicating whether the entry is a directory. `undefined` on error. | ||
@@ -53,0 +53,0 @@ - `symlink` *boolean*: Boolean indicating whether the entry is a symbolic link. `undefined` on error. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11093
176