Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 258 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.