readdir-enhanced
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ module.exports = asyncForEach; |
@@ -1,11 +0,11 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = readdirAsync; | ||
const maybe = require('call-me-maybe'); | ||
const DirectoryReader = require('../directory-reader'); | ||
const maybe = require("call-me-maybe"); | ||
const DirectoryReader = require("../directory-reader"); | ||
let asyncFacade = { | ||
fs: require('fs'), | ||
forEach: require('./for-each'), | ||
fs: require("fs"), | ||
forEach: require("./for-each"), | ||
}; | ||
@@ -23,3 +23,3 @@ | ||
function readdirAsync (dir, options, callback, internalOptions) { | ||
if (typeof options === 'function') { | ||
if (typeof options === "function") { | ||
callback = options; | ||
@@ -37,10 +37,10 @@ options = undefined; | ||
stream.on('error', err => { | ||
stream.on("error", err => { | ||
reject(err); | ||
stream.pause(); | ||
}); | ||
stream.on('data', result => { | ||
stream.on("data", result => { | ||
results.push(result); | ||
}); | ||
stream.on('end', () => { | ||
stream.on("end", () => { | ||
resolve(results); | ||
@@ -47,0 +47,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ let call = module.exports = { |
@@ -1,9 +0,9 @@ | ||
'use strict'; | ||
"use strict"; | ||
const Readable = require('stream').Readable; | ||
const EventEmitter = require('events').EventEmitter; | ||
const path = require('path'); | ||
const normalizeOptions = require('./normalize-options'); | ||
const stat = require('./stat'); | ||
const call = require('./call'); | ||
const Readable = require("stream").Readable; | ||
const EventEmitter = require("events").EventEmitter; | ||
const path = require("path"); | ||
const normalizeOptions = require("./normalize-options"); | ||
const stat = require("./stat"); | ||
const call = require("./call"); | ||
@@ -74,3 +74,3 @@ /** | ||
// fs.readdir threw an error | ||
this.emit('error', err); | ||
this.emit("error", err); | ||
return this.finishedReadingDirectory(); | ||
@@ -90,3 +90,3 @@ } | ||
// (probably because fs.readdir returned an invalid result) | ||
this.emit('error', err2); | ||
this.emit("error", err2); | ||
this.finishedReadingDirectory(); | ||
@@ -160,5 +160,5 @@ } | ||
options.filterFn || // we need fs.Stats for the filter function | ||
EventEmitter.listenerCount(stream, 'file') || // we need the fs.Stats to know if it's a file | ||
EventEmitter.listenerCount(stream, 'directory') || // we need the fs.Stats to know if it's a directory | ||
EventEmitter.listenerCount(stream, 'symlink'); // we need the fs.Stats to know if it's a symlink | ||
EventEmitter.listenerCount(stream, "file") || // we need the fs.Stats to know if it's a file | ||
EventEmitter.listenerCount(stream, "directory") || // we need the fs.Stats to know if it's a directory | ||
EventEmitter.listenerCount(stream, "symlink"); // we need the fs.Stats to know if it's a symlink | ||
@@ -177,3 +177,3 @@ // If we don't need stats, then exit early | ||
// fs.stat threw an error | ||
this.emit('error', err); | ||
this.emit("error", err); | ||
return done(); | ||
@@ -196,3 +196,3 @@ } | ||
basePath: itemPath + options.sep, | ||
posixBasePath: posixPath + '/', | ||
posixBasePath: posixPath + "/", | ||
depth: dir.depth + 1, | ||
@@ -217,3 +217,3 @@ }); | ||
// (probably during a user-specified function, such as options.deep, options.filter, etc.) | ||
this.emit('error', err2); | ||
this.emit("error", err2); | ||
done(); | ||
@@ -256,9 +256,9 @@ } | ||
catch (err) { | ||
this.emit('error', err); | ||
this.emit("error", err); | ||
} | ||
// Also emit specific events, based on the type of chunk | ||
chunk.file && this.emit('file', chunk.data); | ||
chunk.symlink && this.emit('symlink', chunk.data); | ||
chunk.directory && this.emit('directory', chunk.data); | ||
chunk.file && this.emit("file", chunk.data); | ||
chunk.symlink && this.emit("symlink", chunk.data); | ||
chunk.directory && this.emit("directory", chunk.data); | ||
} | ||
@@ -305,3 +305,3 @@ | ||
// In Streaming mode, we emit an "error" event, but continue processing | ||
this.emit('error', err); | ||
this.emit("error", err); | ||
} | ||
@@ -346,3 +346,3 @@ } | ||
// In Streaming mode, we emit an "error" event, but continue processing | ||
this.emit('error', err); | ||
this.emit("error", err); | ||
} | ||
@@ -370,3 +370,3 @@ } | ||
catch (err) { | ||
if (eventName === 'error') { | ||
if (eventName === "error") { | ||
// Don't recursively emit "error" events. | ||
@@ -377,3 +377,3 @@ // If the first one fails, then just throw | ||
else { | ||
stream.emit('error', err); | ||
stream.emit("error", err); | ||
} | ||
@@ -380,0 +380,0 @@ } |
@@ -1,6 +0,6 @@ | ||
'use strict'; | ||
"use strict"; | ||
const readdirSync = require('./sync'); | ||
const readdirAsync = require('./async'); | ||
const readdirStream = require('./stream'); | ||
const readdirSync = require("./sync"); | ||
const readdirAsync = require("./async"); | ||
const readdirStream = require("./stream"); | ||
@@ -7,0 +7,0 @@ module.exports = exports = readdirAsyncPath; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
const path = require('path'); | ||
const globToRegExp = require('glob-to-regexp'); | ||
const path = require("path"); | ||
const globToRegExp = require("glob-to-regexp"); | ||
@@ -58,4 +58,4 @@ module.exports = normalizeOptions; | ||
} | ||
else if (typeof options !== 'object') { | ||
throw new TypeError('options must be an object'); | ||
else if (typeof options !== "object") { | ||
throw new TypeError("options must be an object"); | ||
} | ||
@@ -67,11 +67,11 @@ | ||
} | ||
else if (typeof deep === 'boolean') { | ||
else if (typeof deep === "boolean") { | ||
recurseDepth = deep ? Infinity : 0; | ||
} | ||
else if (typeof deep === 'number') { | ||
else if (typeof deep === "number") { | ||
if (deep < 0 || isNaN(deep)) { | ||
throw new Error('options.deep must be a positive number'); | ||
throw new Error("options.deep must be a positive number"); | ||
} | ||
else if (Math.floor(deep) !== deep) { | ||
throw new Error('options.deep must be an integer'); | ||
throw new Error("options.deep must be an integer"); | ||
} | ||
@@ -82,3 +82,3 @@ else { | ||
} | ||
else if (typeof deep === 'function') { | ||
else if (typeof deep === "function") { | ||
recurseDepth = Infinity; | ||
@@ -91,3 +91,3 @@ recurseFn = deep; | ||
} | ||
else if (typeof deep === 'string' && deep.length > 0) { | ||
else if (typeof deep === "string" && deep.length > 0) { | ||
recurseDepth = Infinity; | ||
@@ -97,3 +97,3 @@ recurseGlob = globToRegExp(deep, { extended: true, globstar: true }); | ||
else { | ||
throw new TypeError('options.deep must be a boolean, number, function, regular expression, or glob pattern'); | ||
throw new TypeError("options.deep must be a boolean, number, function, regular expression, or glob pattern"); | ||
} | ||
@@ -103,3 +103,3 @@ | ||
if (filter !== null && filter !== undefined) { | ||
if (typeof filter === 'function') { | ||
if (typeof filter === "function") { | ||
filterFn = filter; | ||
@@ -110,7 +110,7 @@ } | ||
} | ||
else if (typeof filter === 'string' && filter.length > 0) { | ||
else if (typeof filter === "string" && filter.length > 0) { | ||
filterGlob = globToRegExp(filter, { extended: true, globstar: true }); | ||
} | ||
else { | ||
throw new TypeError('options.filter must be a function, regular expression, or glob pattern'); | ||
throw new TypeError("options.filter must be a function, regular expression, or glob pattern"); | ||
} | ||
@@ -123,4 +123,4 @@ } | ||
} | ||
else if (typeof sep !== 'string') { | ||
throw new TypeError('options.sep must be a string'); | ||
else if (typeof sep !== "string") { | ||
throw new TypeError("options.sep must be a string"); | ||
} | ||
@@ -130,5 +130,5 @@ | ||
if (basePath === null || basePath === undefined) { | ||
basePath = ''; | ||
basePath = ""; | ||
} | ||
else if (typeof basePath === 'string') { | ||
else if (typeof basePath === "string") { | ||
// Append a path separator to the basePath, if necessary | ||
@@ -140,3 +140,3 @@ if (basePath && basePath.substr(-1) !== sep) { | ||
else { | ||
throw new TypeError('options.basePath must be a string'); | ||
throw new TypeError("options.basePath must be a string"); | ||
} | ||
@@ -147,4 +147,4 @@ | ||
let posixBasePath = basePath; | ||
if (posixBasePath && sep !== '/') { | ||
posixBasePath = posixBasePath.replace(new RegExp('\\' + sep, 'g'), '/'); | ||
if (posixBasePath && sep !== "/") { | ||
posixBasePath = posixBasePath.replace(new RegExp("\\" + sep, "g"), "/"); | ||
@@ -154,3 +154,3 @@ /* istanbul ignore if */ | ||
// Convert Windows root paths (C:\) and UNCs (\\) to POSIX root paths | ||
posixBasePath = posixBasePath.replace(/^([a-zA-Z]\:\/|\/\/)/, '/'); | ||
posixBasePath = posixBasePath.replace(/^([a-zA-Z]\:\/|\/\/)/, "/"); | ||
} | ||
@@ -165,3 +165,3 @@ } | ||
} | ||
else if (typeof options.fs === 'object') { | ||
else if (typeof options.fs === "object") { | ||
// Merge the internal facade methods with the user-provided `fs` facades | ||
@@ -172,3 +172,3 @@ facade = Object.assign({}, internalOptions.facade); | ||
else { | ||
throw new TypeError('options.fs must be an object'); | ||
throw new TypeError("options.fs must be an object"); | ||
} | ||
@@ -175,0 +175,0 @@ |
@@ -1,4 +0,4 @@ | ||
'use strict'; | ||
"use strict"; | ||
const call = require('./call'); | ||
const call = require("./call"); | ||
@@ -5,0 +5,0 @@ module.exports = stat; |
@@ -1,10 +0,10 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = readdirStream; | ||
const DirectoryReader = require('../directory-reader'); | ||
const DirectoryReader = require("../directory-reader"); | ||
let streamFacade = { | ||
fs: require('fs'), | ||
forEach: require('../async/for-each'), | ||
fs: require("fs"), | ||
forEach: require("../async/for-each"), | ||
}; | ||
@@ -11,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -3,0 +3,0 @@ module.exports = syncForEach; |
@@ -1,5 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
const fs = require('fs'); | ||
const call = require('../call'); | ||
const fs = require("fs"); | ||
const call = require("../call"); | ||
@@ -6,0 +6,0 @@ /** |
@@ -1,10 +0,10 @@ | ||
'use strict'; | ||
"use strict"; | ||
module.exports = readdirSync; | ||
const DirectoryReader = require('../directory-reader'); | ||
const DirectoryReader = require("../directory-reader"); | ||
let syncFacade = { | ||
fs: require('./fs'), | ||
forEach: require('./for-each'), | ||
fs: require("./fs"), | ||
forEach: require("./for-each"), | ||
}; | ||
@@ -11,0 +11,0 @@ |
{ | ||
"name": "readdir-enhanced", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "fs.readdir with sync, async, and streaming APIs + filtering, recursion, absolute paths, etc.", | ||
@@ -19,3 +19,3 @@ "keywords": [ | ||
}, | ||
"homepage": "https://github.com/JS-DevTools/readdir-enhanced", | ||
"homepage": "https://jsdevtools.org/readdir-enhanced", | ||
"repository": { | ||
@@ -31,3 +31,3 @@ "type": "git", | ||
"scripts": { | ||
"lint": "eslint lib test --fix", | ||
"lint": "eslint lib test", | ||
"test": "mocha && npm run lint", | ||
@@ -41,13 +41,12 @@ "coverage": "nyc --reporter=text --reporter=lcov mocha", | ||
"chai": "^4.2.0", | ||
"codacy-coverage": "^3.1.0", | ||
"coveralls": "^3.0.2", | ||
"del": "^3.0.0", | ||
"eslint": "^5.6.1", | ||
"eslint-config-modular": "^4.2.2", | ||
"eslint": "^5.10.0", | ||
"eslint-config-modular": "^5.0.1", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^5.2.0", | ||
"npm-check": "^5.9.0", | ||
"nyc": "^13.0.1", | ||
"through2": "^2.0.3", | ||
"version-bump-prompt": "^4.2.1" | ||
"nyc": "^13.1.0", | ||
"through2": "^3.0.0", | ||
"version-bump-prompt": "^4.2.2" | ||
}, | ||
@@ -54,0 +53,0 @@ "dependencies": { |
Enhanced `fs.readdir()` | ||
======================= | ||
[![Build Status](https://api.travis-ci.org/JS-DevTools/readdir-enhanced.svg?branch=master)](https://travis-ci.org/JS-DevTools/readdir-enhanced) | ||
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/JS-DevTools/readdir-enhanced?svg=true&branch=master&failingText=Windows%20build%20failing&passingText=Windows%20build%20passing)](https://ci.appveyor.com/project/JamesMessinger/readdir-enhanced/branch/master) | ||
[![Cross-Platform Compatibility](https://jsdevtools.org/img/badges/os-badges.svg)](https://travis-ci.com/JS-DevTools/simplifyify) | ||
[![Build Status](https://api.travis-ci.com/JS-DevTools/readdir-enhanced.svg?branch=master)](https://travis-ci.com/JS-DevTools/readdir-enhanced) | ||
[![Coverage Status](https://coveralls.io/repos/github/JS-DevTools/readdir-enhanced/badge.svg?branch=master)](https://coveralls.io/github/JS-DevTools/readdir-enhanced?branch=master) | ||
[![Codacy Score](https://api.codacy.com/project/badge/Grade/178a817b6c864de7813fef457c0ed5ae)](https://www.codacy.com/public/JamesMessinger/readdir-enhanced) | ||
[![Inline docs](https://inch-ci.org/github/JS-DevTools/readdir-enhanced.svg?branch=master&style=shields)](https://inch-ci.org/github/JS-DevTools/readdir-enhanced) | ||
[![Dependencies](https://david-dm.org/JS-DevTools/readdir-enhanced.svg)](https://david-dm.org/JS-DevTools/readdir-enhanced) | ||
@@ -326,3 +324,3 @@ | ||
-------------------------- | ||
I welcome any contributions, enhancements, and bug-fixes. [File an issue](https://github.com/JS-DevTools/readdir-enhanced/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/readdir-enhanced/pulls). | ||
Contributions, enhancements, and bug-fixes are welcome! [File an issue](https://github.com/JS-DevTools/readdir-enhanced/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/readdir-enhanced/pulls). | ||
@@ -347,1 +345,10 @@ #### Building | ||
Big Thanks To | ||
-------------------------- | ||
Thanks to these awesome companies for their support of Open Source developers ❤ | ||
[![Travis CI](https://jsdevtools.org/img/badges/travis-ci.svg)](https://travis-ci.com) | ||
[![SauceLabs](https://jsdevtools.org/img/badges/sauce-labs.svg)](https://saucelabs.com) | ||
[![Coveralls](https://jsdevtools.org/img/badges/coveralls.svg)](https://coveralls.io) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
11
353
50716
1