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

readdirp

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readdirp - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

2

index.d.ts

@@ -20,3 +20,3 @@ // TypeScript Version: 3.2

fileFilter?: string | string[] | ((entry: EntryInfo) => boolean);
directoryFilter?: (entry: EntryInfo) => boolean;
directoryFilter?: string | string[] | ((entry: EntryInfo) => boolean);
type?: 'files' | 'directories' | 'files_directories' | 'all';

@@ -23,0 +23,0 @@ lstat?: boolean;

@@ -12,2 +12,3 @@ 'use strict';

const lstat = promisify(fs.lstat);
const realpath = promisify(fs.realpath);

@@ -110,7 +111,3 @@ /**

// Launch stream with one parent, the root dir.
try {
this.parents = [this._exploreDir(root, 1)];
} catch (error) {
this.destroy(error);
}
this.parents = [this._exploreDir(root, 1)];
this.reading = false;

@@ -131,3 +128,6 @@ this.parent = undefined;

for (const entry of await Promise.all(slice)) {
if (this._isDirAndMatchesFilter(entry)) {
if (this.destroyed) return;
const entryType = await this._getEntryType(entry);
if (entryType === 'directory' && this._directoryFilter(entry)) {
if (depth <= this._maxDepth) {

@@ -141,3 +141,3 @@ this.parents.push(this._exploreDir(entry.fullPath, depth + 1));

}
} else if (this._isFileAndMatchesFilter(entry)) {
} else if ((entryType === 'file' || this._includeAsFile(entry)) && this._fileFilter(entry)) {
if (this._wantsFile) {

@@ -156,2 +156,3 @@ this.push(entry);

this.parent = await parent;
if (this.destroyed) return;
}

@@ -177,6 +178,7 @@ }

async _formatEntry(dirent, path) {
const basename = this._isDirent ? dirent.name : dirent;
const fullPath = sysPath.resolve(sysPath.join(path, basename));
const entry = {path: sysPath.relative(this._root, fullPath), fullPath, basename};
let entry;
try {
const basename = this._isDirent ? dirent.name : dirent;
const fullPath = sysPath.resolve(sysPath.join(path, basename));
entry = {path: sysPath.relative(this._root, fullPath), fullPath, basename};
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);

@@ -193,20 +195,39 @@ } catch (err) {

} else {
throw err;
this.destroy(err);
}
}
_isDirAndMatchesFilter(entry) {
async _getEntryType(entry) {
// entry may be undefined, because a warning or an error were emitted
// and the statsProp is undefined
const stats = entry && entry[this._statsProp];
return stats && stats.isDirectory() && this._directoryFilter(entry);
if (!stats) {
return;
}
if (stats.isFile()) {
return 'file';
}
if (stats.isDirectory()) {
return 'directory';
}
if (stats && stats.isSymbolicLink()) {
try {
const entryRealPath = await realpath(entry.fullPath);
const entryRealPathStats = await lstat(entryRealPath);
if (entryRealPathStats.isFile()) {
return 'file';
}
if (entryRealPathStats.isDirectory()) {
return 'directory';
}
} catch (error) {
this._onError(error);
}
}
}
_isFileAndMatchesFilter(entry) {
_includeAsFile(entry) {
const stats = entry && entry[this._statsProp];
const isFileType = stats && (
(this._wantsEverything && !stats.isDirectory()) ||
(stats.isFile() || stats.isSymbolicLink())
);
return isFileType && this._fileFilter(entry);
return stats && this._wantsEverything && !stats.isDirectory();
}

@@ -213,0 +234,0 @@ }

{
"name": "readdirp",
"description": "Recursive version of fs.readdir with streaming API.",
"version": "3.3.0",
"version": "3.4.0",
"homepage": "https://github.com/paulmillr/readdirp",

@@ -45,12 +45,12 @@ "repository": {

"dependencies": {
"picomatch": "^2.0.7"
"picomatch": "^2.2.1"
},
"devDependencies": {
"@types/node": "^12",
"@types/node": "^13",
"chai": "^4.2",
"chai-subset": "^1.6",
"dtslint": "^2.0.0",
"dtslint": "^3.3.0",
"eslint": "^6.6.0",
"mocha": "^6.2.2",
"nyc": "^14.1.1",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"rimraf": "^3.0.0"

@@ -57,0 +57,0 @@ },

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