Socket
Book a DemoInstallSign in
Socket

load-folder

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-folder

Load a folder as an object

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
1
Created
Source

Install

npm install load-folder

Usage example

Your structure

project
│   README.md
│   file001.txt    
│
└───controllers
│   │   controller1.js
│   │   controller2.js
│   │   ...
...

You need do var controller1 = require('./controllers/controller1')

With this module...

In controller folder, create index.js and copy/paste

module.exports = require('load-folder')({respect: true}); // see code for respect option

Now you can do var controllers = require('/controllers') and this is an object like:

{
  controller1: module,
  controller2: module
}

Keywords

nodejs

FAQs

Package last updated on 15 Nov 2017

Did you know?

Socket

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.

Install

Related posts