node-require-context

1.0.0 • Public • Published

node-require-context

same as webpack => require.context

Usage

npm i --save node-require-context

Example

const requireContext = require('node-require-context')
const context = requireContext('.', true, /\.js$/)
context.keys().forEach(moduleId=>{
    context(moduleId)
})

API

requireContext ( directory, useSubdirectories, regExp )

  • directory

search dir default '.'

  • useSubdirectories

true will search all child file ; false only search current dir ; default true

  • regExp

RegExp match ; default /(?:)/

Readme

Keywords

Package Sidebar

Install

npm i node-require-context

Weekly Downloads

498

Version

1.0.0

License

MIT

Unpacked Size

3.21 kB

Total Files

3

Last publish

Collaborators

  • itlzi