Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rrdir

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrdir - npm Package Compare versions

Comparing version 6.1.3 to 7.0.0

65

index.js

@@ -11,3 +11,3 @@ "use strict";

stats: false,
followSymlinks: true,
followSymlinks: false,
exclude: undefined,

@@ -24,5 +24,14 @@ include: undefined,

function build(dirent, path, stats) {
const entry = {path, directory: dirent.isDirectory(), symlink: dirent.isSymbolicLink()};
if (stats) entry.stats = stats;
function makePath(entry, dir) {
return dir === "." ? entry.name : `${dir}${sep}${entry.name}`;
}
function build(dirent, path, stats, opts) {
// console.log(path, stats.isSymbolicLink(), dirent.isSymbolicLink());
const entry = {
path,
directory: stats ? stats.isDirectory() : dirent.isDirectory(),
symlink: stats ? stats.isSymbolicLink() : dirent.isSymbolicLink(),
};
if (opts.stats) entry.stats = stats;
return entry;

@@ -60,3 +69,3 @@ }

await Promise.all(entries.map(async entry => {
const path = dir === "." ? entry.name : `${dir}${sep}${entry.name}`;
const path = makePath(entry, dir);
if (excludeMatcher(path)) return;

@@ -67,3 +76,3 @@

try {
stats = await (opts.followSymlinks ? stat(path) : lstat(path));
stats = await (opts.followSymlinks ? stat : lstat)(path);
} catch (err) {

@@ -75,4 +84,12 @@ if (opts.strict) throw err;

if (includeMatcher(path)) results.push(build(entry, path, stats));
if (entry.isDirectory()) results.push(...await rrdir(path, opts, {includeMatcher, excludeMatcher}));
let recurse = false;
if (opts.followSymlinks && entry.isSymbolicLink()) {
if (!stats) try { stats = await stat(path) } catch {}
if (stats && stats.isDirectory()) recurse = true;
} else if (entry.isDirectory()) {
recurse = true;
}
if (includeMatcher(path)) results.push(build(entry, path, stats, opts));
if (recurse) results.push(...await rrdir(path, opts, {includeMatcher, excludeMatcher}));
}));

@@ -105,3 +122,3 @@

for (const entry of entries) {
const path = dir === "." ? entry.name : `${dir}${sep}${entry.name}`;
const path = makePath(entry, dir);
if (excludeMatcher(path)) continue;

@@ -112,3 +129,3 @@

try {
stats = opts.followSymlinks ? statSync(path) : lstatSync(path);
stats = (opts.followSymlinks ? statSync : lstatSync)(path);
} catch (err) {

@@ -120,4 +137,12 @@ if (opts.strict) throw err;

if (includeMatcher(path)) results.push(build(entry, path, stats));
if (entry.isDirectory()) results.push(...rrdir.sync(path, opts, {includeMatcher, excludeMatcher}));
let recurse = false;
if (opts.followSymlinks && entry.isSymbolicLink()) {
if (!stats) try { stats = statSync(path) } catch {}
if (stats && stats.isDirectory()) recurse = true;
} else if (entry.isDirectory()) {
recurse = true;
}
if (includeMatcher(path)) results.push(build(entry, path, stats, opts));
if (recurse) results.push(...rrdir.sync(path, opts, {includeMatcher, excludeMatcher}));
}

@@ -149,3 +174,3 @@

for (const entry of entries) {
const path = dir === "." ? entry.name : `${dir}${sep}${entry.name}`;
const path = makePath(entry, dir);
if (excludeMatcher && excludeMatcher(path)) continue;

@@ -156,3 +181,3 @@

try {
stats = await (opts.followSymlinks ? stat(path) : lstat(path));
stats = await (opts.followSymlinks ? stat : lstat)(path);
} catch (err) {

@@ -164,5 +189,13 @@ if (opts.strict) throw err;

if (includeMatcher(path)) yield build(entry, path, stats);
if (entry.isDirectory()) yield* await rrdir.stream(path, opts, {includeMatcher, excludeMatcher});
let recurse = false;
if (opts.followSymlinks && entry.isSymbolicLink()) {
if (!stats) try { stats = await stat(path) } catch {}
if (stats && stats.isDirectory()) recurse = true;
} else if (entry.isDirectory()) {
recurse = true;
}
if (includeMatcher(path)) yield build(entry, path, stats, opts);
if (recurse) yield* await rrdir.stream(path, opts, {includeMatcher, excludeMatcher});
}
};
{
"name": "rrdir",
"version": "6.1.3",
"version": "7.0.0",
"description": "Recursive directory reader with a delightful API",

@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io>",

@@ -40,5 +40,5 @@ # rrdir

- `options.stats` *boolean*: Whether to include `entry.stats`. Will reduce performance. Default: `false`.
- `options.followSymlinks` *boolean*: Whether to follow symlinks when `options.stats` is enabled. Default: `true`.
- `options.exclude` *Array*: Path globs to exclude. Default: `undefined`.
- `options.include` *Array*: Path globs to include. Default: `undefined`.
- `options.followSymlinks` *boolean*: Whether to follow symlinks when `options.stats` is enabled. Default: `false`.
- `options.exclude` *Array*: Path globs to exclude, e.g. `["**/*.js"]`. Default: `undefined`.
- `options.include` *Array*: Path globs to include, e.g. `["**/*.map"]`. Default: `undefined`.
- `options.strict` *boolean*: Whether to throw immediately when reading an entry fails. Default: `false`.

@@ -45,0 +45,0 @@ - `options.match` *Object*: [picomatch options](https://github.com/micromatch/picomatch#options). Default: `{dot: true}`.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc