Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
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|Number|null]deep
to [Number]
[see below]deep
to null
[see below]deep
[Number|null] (default:null
)
It indicates how deep the list-contents
should explore the folders in the given path
directory.null
(default) it lists all subfiles and subfolders of all levels of the path
directory.1
it lists only the folders and files of the path
directory.2
it lists the elements of the path
directory and the contents of the path
directory's folders.exclude
[Array|String]files
, dirs
and inaccessible
lists."./bin"
.
When [Array], it can indicate more than one path to ignore, eg. ["./node_modules", "./bin"]
.path
.'./node_modules'
or './.git'
to make the module faster.const listContents = require('list-contents');
listContents('./dist', (data)=>{/*...*/});
listContents('./dist', null, (data)=>{/*...*/});
listContents('./dist', 3, (data)=>{/*...*/});
listContents('./dist', {deep: 5}, (data)=>{/*...*/});
listContents('./dist', {deep: 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
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
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.