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

node-readfiles

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-readfiles - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

38

lib/readfiles.js

@@ -26,16 +26,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

const filter = filters.shift();
filterArray.push('\\/?' +
filter
.replace(/\./g, '\\.')
.replace(/(\*?)(\*)(?!\*)/g, function (match, prefix) {
if (prefix == '*') {
return match;
}
return '[^\\/]*';
})
.replace(/\?/g, '[^\\/]?')
.replace(/\*\*/g, '.*')
.replace(/([\-\+\|])/g, '\\$1'));
filterArray.push(`\\/?${filter
.replace(/([./\\])/g, '\\$1')
.replace(/(\*?)(\*)(?!\*)/g, (match, prefix) => {
if (prefix === '*') {
return match;
}
return '[^\\/]*';
})
.replace(/\?/g, '[^\\/]?')
.replace(/\*\*/g, '.*')
.replace(/([\-\+\|])/g, '\\$1')}`);
}
return new RegExp('^' + filterArray.join('|') + '$', 'i');
return new RegExp(`^${filterArray.join('|')}$`, 'i');
};

@@ -48,2 +47,6 @@ exports.buildFilter = buildFilter;

describe('buildFilter', () => {
it('creates a filter RegExp given a filter string', () => {
const result = (0, build_filter_1.buildFilter)('.');
expect(result).toEqual(/^\/?\.$/i);
});
it('creates a filter RegExp given a wildcard filter string', () => {

@@ -92,3 +95,4 @@ const result = (0, build_filter_1.buildFilter)('*');

const traverseDir = (dirPath, done) => {
fs.readdir(dirPath, (err, fileList) => {
fs.readdir(dirPath, (err, fileListProp) => {
let fileList = fileListProp;
if (err) {

@@ -136,3 +140,3 @@ if (options.rejectOnError !== false) {

else if (stat.isFile()) {
if (filterRegExp && !filterRegExp.test('/' + relFilename)) {
if (filterRegExp && !filterRegExp.test(`/${relFilename}`)) {
return next();

@@ -448,3 +452,3 @@ }

it("callback returns the relative path of the files when 'filenameFormat' is 'readfiles.RELATIVE'", done => {
let count = 0;
const count = 0;
const expectFiles = [

@@ -477,3 +481,3 @@ 'abc.txt',

it("callback returns only the filename of the file when 'filenameFormat' is 'readfiles.FILENAME'", done => {
let count = 0;
const count = 0;
const expectFiles = [

@@ -480,0 +484,0 @@ 'abc.txt',

{
"name": "node-readfiles",
"version": "0.3.0",
"version": "0.3.1",
"description": "A lightweight Node.js module to recursively read files in a directory using ES6 Promises",

@@ -5,0 +5,0 @@ "main": "lib/readfiles.js",

@@ -11,3 +11,3 @@ export const buildFilter = (filtersParam: string | string[]) => {

`\\/?${filter
.replace(/\./g, '\\.')
.replace(/([./\\])/g, '\\$1')
.replace(/(\*?)(\*)(?!\*)/g, (match, prefix) => {

@@ -14,0 +14,0 @@ if (prefix === '*') {

import { buildFilter } from './build-filter';
describe('buildFilter', () => {
it('creates a filter RegExp given a filter string', () => {
const result = buildFilter('.');
expect(result).toEqual(/^\/?\.$/i);
});
it('creates a filter RegExp given a wildcard filter string', () => {

@@ -5,0 +11,0 @@ const result = buildFilter('*');

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