build-lib-from-path

0.0.5 • Public • Published

build-lib-from-path

A simple tool that takes a base path and an optional string/regex matcher as arguments and create a library based on the flies within the given base path.

Getting Started

Installation:

npm install --save build-lib-from-path

Usage:

const BuildLib = require('build-lib-from-path');

let path = './controllers';   // a target lib folder.
let lib = BuildLib.fromPath(path);

will recursively load all the modules in the given path, arranging them within the returned object per their directory structure.

If you want to filter by class name, you can use a regex or a string matcher.

const BuildLib = require('build-lib-from-path');

let path = './controllers';       // a target lib folder.
let matcher = /^\w+Controller$/;  // catch only Controller classes.

let lib = BuildLib.fromPath(path, matcher);

will cause the output to be filtered by the given string or regex, applied to the imported class' name.

Configuration:

BuildLib.Configuration.namePrefix = <STRING>
      prepend <STRING> to object names.

BuildLib.Configuration.nameSuffix = <STRING>
      append <STRING> to object names.

BuildLib.Configuration.camelCaseNames = <BOOLEAN>
      use CamelCase object names.

BuildLib.Configuration.snakeCaseNames = <BOOLEAN>
      use snake_case object names.

Notes

  • Assumes that file names are in snake case. ie: test_filename.js

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i build-lib-from-path

    Weekly Downloads

    5

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    18.7 kB

    Total Files

    22

    Last publish

    Collaborators

    • sal-ortiz