Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
scandirectory
Advanced tools
Scan a directory recursively with a lot of control and power
var scandir = require('scandirectory')
var path = process.cwd()
var options = {}
function completionCallback(err, list, tree) {
console.log({
error: err,
list: list,
tree: tree,
})
/*
{
error: null,
list: {
'a file.txt': 'file',
'a directory': 'dir',
'a directory/a sub file.txt': 'file'
},
tree: {
'a file.txt': true,
'a directory': {
'a sub file.txt': 'true
}
}
}
*/
}
scandir(path, options, completionCallback)
Scan directory options:
action
- (default null
) can be null
or a function to use for both the fileAction and dirActionfileAction
- (default null
) can be null
, false
, or a function to be the action callbackdirAction
- (default null
) can be null
, false
, or a function to the action callbackrecurse
- (default true
) can be null
or a boolean for whether or not to scan subdirectories tooreadFiles
- (default false
) can be null
or a boolean for whether or not we should read the file contentsThe options object is also sent to ignorefs so you can use its options too
The completion callback accepts the following arguments:
err
- null
or an error that has occuredlist
- a collection of all the child nodes in a list/object format: - {fileRelativePath: 'dir|file'}
tree
- a collection of all the child nodes in a tree format: - {dir: {dir:{}, file1:true} }
- if the readFiles option is true, then files will be returned with their contents insteadThe results for a specific argument is only generated if the argument is requested.
The action callbacks accept the following arguments:
fullPath
- the full/absolute path of the current file/directoryrelativePath
- the relative path of the current file/directory with respect to the original scanning pathfilename
- the basename of the current file/directorystat
- a simple stat object provided by readdir-clusterThe action callbacks can return false
to skip the path from being processed further.
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
npm install --save scandirectory
import * as pkg from ('scandirectory')
const pkg = require('scandirectory')
This package is published with the following editions:
scandirectory
aliases scandirectory/index.cjs
which uses the Editions Autoloader to automatically select the correct edition for the consumer's environmentscandirectory/source/index.js
is ESNext source code for Node.js 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with Require for modulesscandirectory/edition-node-4/index.js
is ESNext compiled for Node.js 4 with Require for modulesDiscover the release history by heading on over to the HISTORY.md
file.
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Unless stated otherwise all works are:
and licensed under:
v7.1.0 2023 November 15
FAQs
Scan a directory recursively with a lot of control and power
The npm package scandirectory receives a total of 12,831 weekly downloads. As such, scandirectory popularity was classified as popular.
We found that scandirectory demonstrated a healthy version release cadence and project activity because the last version was released less than 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.