Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
list-contents
Advanced tools
Returns a list of paths to the subfolders and subfiles of the specified location.
list-contents
is a module that returns a list of paths to the subfolders and subfiles of the specified location.
file-assistant
package that creates, copies or moves the folders and files into the specified path or modifies the files' content according to the given [Array] object (or .json file path) instructions.npm install list-contents
const list = require('list-contents');
list(path,[config,]callback)
path
[String]config
[Object]list-contents
module with the following [Object] config
's properties:
depth
[Number|null] (default:null)list-contents
module should explore the folders in the given path
directory.null
(default) - it lists all subfiles and subfolders of all levels of the path
directory.path
directory elements; eg. ./styles
, ./index.html
.path
directory elements; eg. ./styles/css
, ./scripts/ajax.js
exclude
[Array|String] (default:[])files
, dirs
and inaccessible
lists."./bin"
.["./node_modules", "./bin"]
.path
, otherwise they will be not recognized.'./node_modules'
or './.git'
to make the list-contents
module faster.const listContents = require('list-contents');
listContents('./dist', (data)=>{/*...*/});
listContents('./dist', {depth: 5}, (data)=>{/*...*/});
listContents('./dist', {depth: 3, exclude: ['node_modules','.git']}, (data)=>{/*...*/})
callback
[Function]callback
function. It has 5 properties:
error
[Boolean|Error]
null
if the path
is valid, otherwise [Error] objectdirs
[Array]path
argumentfiles
[Array]path
argumentinaccessible
[Array] v3.*.*
path
argument.path
[String]path
parameterconst list = require('list-contents');
list("./dist",(o)=>{
if(o.error) throw o.error;
console.log('Folders: ', o.dirs);
console.log('Files: ', o.files);
});
Assuming that "./dist" path contains the following subfolders and subfiles:
dist
├ scripts
│ ├ index.js
│ └ ajax.js
├ styles
│ ├ css
│ │ ├ layout.css
│ │ └ media.css
│ └ scss
│ └ mixins.scss
└ templates
├ main.html
├ menubar.html
├ login.html
└ contact.html
the module will pass the following object through the callback
function:
{
error: null,
path: "./dist",
dirs: [
'scripts',
'templates',
'styles',
'styles/css',
'styles/scss'
],
files: [
'scripts/ajax.js',
'scripts/index.js',
'templates/contact.html',
'templates/login.html',
'templates/main.html',
'templates/menubar.html',
'styles/css/layout.css',
'styles/css/media.css',
'styles/scss/mixins.scss'
],
inaccessible: []
}
FAQs
Returns a list of paths to the subfolders and subfiles of the specified location.
The npm package list-contents receives a total of 236 weekly downloads. As such, list-contents popularity was classified as not popular.
We found that list-contents 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.