Socket
Socket
Sign inDemoInstall

wrapper-path

Package Overview
Dependencies
0
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.2 to 2.1.0

2

package.json
{
"name": "wrapper-path",
"version": "2.0.2",
"version": "2.1.0",
"description": "wrapper to path module, to simple require, get and others",

@@ -5,0 +5,0 @@ "main": "Path.js",

@@ -23,3 +23,3 @@ 'use strict';

if (dir.charAt(0) !== '/') throw new Error('Invalid path');
if (!dir.startsWith(this.pathRoot)) return `${this.pathRoot}${dir}`;
if (!dir.startsWith(this.pathRoot)) return `${this.pathRoot}${dir}`;
return dir;

@@ -58,13 +58,15 @@ }

return {
files: function recursiveFiles(dir, opts, filelist) {
files: function recursiveFiles(dir, opts, filelist, currentDepth = 0) {
const {match, exclude, maxDepth = -1} = opts || {};
if (maxDepth !== -1 && currentDepth === maxDepth)
return filelist;
dir = self.get(dir);
filelist = filelist || [];
let files = self._getFiles(dir);
const files = self._getFiles(dir);
for (let i = files.length - 1; i >= 0; i--) {
let file = files[i];
if (self._isDirectory(`${dir}${file}`))
recursiveFiles(`${dir}${file}`, opts, filelist);
recursiveFiles(`${dir}${file}`, opts, filelist, currentDepth + 1);
else {
let flag = true,
{match, exclude} = opts || {};
let flag = true;
flag &= (match) ? match.test(`${dir}${file}`) : flag;

@@ -78,11 +80,13 @@ flag &= (exclude) ? !exclude.test(`${dir}${file}`) : flag;

},
folders: function recursiveFolders(dir, opts, folderlist) {
folders: function recursiveFolders(dir, opts, folderlist, currentDepth = 0) {
const {match, exclude, maxDepth = 0} = opts || {};
if (maxDepth > 0 && currentDepth === maxDepth)
return folderlist;
dir = self.get(dir);
folderlist = folderlist || [];
let files = self._getFiles(dir);
const files = self._getFiles(dir);
for (let i = files.length - 1; i >= 0; i--) {
let file = files[i];
const file = files[i];
if (self._isDirectory(`${dir}${file}`)) {
let flag = true,
{match, exclude} = opts || {};
let flag = true;
flag &= (match) ? match.test(`${dir}${file}`) : flag;

@@ -92,3 +96,3 @@ flag &= (exclude) ? !exclude.test(`${dir}${file}`) : flag;

folderlist.push(`${dir}${file}`);
return recursiveFolders(`${dir}${file}`, opts, folderlist);
return recursiveFolders(`${dir}${file}`, opts, folderlist, currentDepth + 1);
}

@@ -110,10 +114,10 @@ }

if (/ENOTEMPTY/g.test(e)) {
let files = self.recursive.files(dir);
const files = self.recursive.files(dir);
for (let i = files.length - 1; i >= 0; i--) {
let file = files[i];
const file = files[i];
fs.unlinkSync(self.get(file));
}
let folders = self.recursive.folders(dir);
const folders = self.recursive.folders(dir);
for (let i = folders.length - 1; i >= 0; i--) {
let folder = folders[i];
const folder = folders[i];
fs.rmdirSync(self.get(folder));

@@ -120,0 +124,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc