Skip to content

simbo/requirements-mapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

requirements-mapper

Auto-require all matching files within a directory recursively and return them as single object, representing the directory's structure.

npm Package Version MIT License Travis Build Status Code Climate GPA Code Climate Test Coverage

Dependencies Status devDependencies Status


Usage

var ReqMapper = require('requirements-mapper'),
    dataMapper = new ReqMapper('./data')),
    dataMap = dataMapper.map();

Example

Assuming that ./data is a directory containing multiple files using subfolders like this:

data/
 ├─╸ other/
 │    ├─╸ bar.js
 │    └─╸ baz.json
 └─╸ foo.js

An object of which every node contains the required contents of the respective file will be returned by RequirementsMapper.map():

{
    other: {
        bar: 
        baz: 
    },
    foo: 
}

Options

The constructor of RequirementsMapper accepts 3 parameters:

  • dir - directory to scan; defaults to process.cwd()
  • globPattern - globbing pattern for finding files; defaults to **/*.js?(on)
  • clearCache - clear the require cache for a node, before requiring it; defaults to true

See node-glob for more details on globbing options.

License

MIT Simon Lepel 2015

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published