Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
require-tree
Advanced tools
Require multiple files at once, creating an object tree that mirrors the directory structure.
npm install require-tree
var require_tree = require('require-tree')
// File structure:
// ./models
// user.js
// page.js
// item.js
require_tree('./models')
// {
// user: [object Object],
// page: [object Object],
// item: [object Object]
// }
With nested directories:
// ./api
// /pages
// index.js
// edit.js
// user.js
// api/pages/index.js:
module.exports = {
list: function(){ ... }
}
// api/pages/edit.js:
module.exports = {
getPermissions: function(){ ... },
remove: function(){ ... }
}
// api/user.js:
module.exports = {
profile: function(){ ... },
posts: function(){ ... }
}
var api = require_tree('./api')
// api.pages.list
// api.pages.edit.getPermissions
// api.pages.edit.remove
// api.user.profile
// api.user.posts
Since v0.3 require-tree
will resolve paths relative to the requiring module, like require
itself.
Since it depends on module.parent
being set correctly, either require-tree
must be explicitly required within the current module scope, or you need to provide an absolute path like __dirname + '/somepath'
.
{
name : [String | Function(exports, file)] // the object's property to use as key
main : [String | Array | Function(exports, file)] // what keys should be exported
index : [Boolean] // load 'index.js' files (`true` by default)
filter : [String | RegExp | Function] // filter pattern
each : [Function] // callback to run after each module
}
FAQs
Batch module loader, require() for directories
The npm package require-tree receives a total of 6,186 weekly downloads. As such, require-tree popularity was classified as popular.
We found that require-tree 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
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.