
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
dir-to-json
Advanced tools
Asynchronously convert directory tree structure into a JavaScript object.
Yarn:
yarn add dir-to-json
NPM:
npm install dir-to-json --save
import dirToJson from "dir-to-json";
dirToJson("./path/to/my/dir", { sortType: true })
.then(function (dirTree) {
console.log(dirTree);
})
.catch(function (err) {
throw err;
});
The callback syntax has been split into another module in version 1.0.0
. If you would still like to use it, just change your import to dir-to-json/callback
:
import dirToJson from "dir-to-json/callback";
dirToJson("./path/to/my/dir", function (err, dirTree) {
if (err) {
throw err;
} else {
console.log(dirTree);
}
});
Since Version 1.0.0 of
dir-to-json
, the lowest supported version of NodeJS is14
. If you are using an older version of Node, try installingdir-to-json@0.0.3
dirToJson( path [, options ] [, callback ] )
true
) - If true
, directories will be listed before files in all children
arrays. If false
, array contents will be listed in the order which they are returned from fs.readdir()
.null
on success.{
"parent": "..",
"path": "",
"name": "coverage",
"type": "directory",
"children": [{
"parent": "",
"path": "coverage-final.json",
"name": "coverage-final.json",
"type": "file"
}, {
"parent": "",
"path": "index.html",
"name": "index.html",
"type": "file"
}, {
"parent": "",
"path": "lcov-report",
"name": "lcov-report",
"type": "directory",
"children": [{
"parent": "lcov-report",
"path": "lcov-report/index.html",
"name": "index.html",
"type": "file"
}, {
"parent": "lcov-report",
"path": "lcov-report/prettify.css",
"name": "prettify.css",
"type": "file"
}, {
"parent": "lcov-report",
"path": "lcov-report/prettify.js",
"name": "prettify.js",
"type": "file"
}, {
"parent": "lcov-report",
"path": "lcov-report/src",
"name": "src",
"type": "directory",
"children": [{
"parent": "lcov-report/src",
"path": "lcov-report/src/createDirectoryObject.js.html",
"name": "createDirectoryObject.js.html",
"type": "file"
}, {
"parent": "lcov-report/src",
"path": "lcov-report/src/index.html",
"name": "index.html",
"type": "file"
}, {
"parent": "lcov-report/src",
"path": "lcov-report/src/main.js.html",
"name": "main.js.html",
"type": "file"
}]
}]
}, {
"parent": "",
"path": "lcov.info",
"name": "lcov.info",
"type": "file"
}, {
"parent": "",
"path": "prettify.css",
"name": "prettify.css",
"type": "file"
}, {
"parent": "",
"path": "prettify.js",
"name": "prettify.js",
"type": "file"
}, {
"parent": "",
"path": "src",
"name": "src",
"type": "directory",
"children": [{
"parent": "src",
"path": "src/createDirectoryObject.js.html",
"name": "createDirectoryObject.js.html",
"type": "file"
}, {
"parent": "src",
"path": "src/index.html",
"name": "index.html",
"type": "file"
}, {
"parent": "src",
"path": "src/main.js.html",
"name": "main.js.html",
"type": "file"
}]
}]
}
MIT. Copyright © 2022 Travis Wimer
FAQs
Asynchronously convert directory tree structure into a javascript object.
We found that dir-to-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.