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

directory-tree

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory-tree - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

21

lib/directory-tree.js

@@ -18,9 +18,18 @@ 'use strict';

item.size = stats.size; // File size in bytes
item.extension = ext;
}
else {
item.children = FS.readdirSync(path)
.map(child => directoryTree(PATH.join(path, child), extensions))
.filter(e => !!e);
if (!item.children.length) return null;
item.size = item.children.reduce((prev, cur) => prev + cur.size, 0);
else if (stats.isDirectory()) {
try {
item.children = FS.readdirSync(path)
.map(child => directoryTree(PATH.join(path, child), extensions))
.filter(e => !!e);
if (!item.children.length) return null;
item.size = item.children.reduce((prev, cur) => prev + cur.size, 0);
} catch(ex) {
if (ex.code == "EACCES")
//User does not have permissions, ignore directory
return null;
}
} else {
return null; // Or set item.size = 0 for devices, FIFO and sockets ?
}

@@ -27,0 +36,0 @@ return item;

{
"name": "directory-tree",
"version": "1.0.0",
"version": "1.1.0",
"description": "Convert a directory tree to a JS object.",

@@ -5,0 +5,0 @@ "repository": {

@@ -61,4 +61,5 @@ [![Build Status](https://travis-ci.org/mihneadb/node-directory-tree.svg)](https://travis-ci.org/mihneadb/node-directory-tree)

"path": "photos/summer/june/windsurf.jpg",
"name": "windsurf.jpg",
"size": 400,
"name": "windsurf.jpg",
"extension": ".jpg"
}

@@ -83,2 +84,3 @@ ]

"size": 100,
"extension": ".png"
},

@@ -89,2 +91,3 @@ {

"size": 100,
"extension": ".jpg"
}

@@ -98,5 +101,9 @@ ]

```
## Note
Device, FIFO and socket files are ignored.
Files to which the user does not have permissions are included in the directory
tree, however, directories to which the user does not have permissions, along
with all of its contained files, are completely ignored.
## Dev

@@ -116,2 +123,1 @@

Check out version `0.1.1` if you need support for older versions of node.

Sorry, the diff of this file is not supported yet

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