This package has been deprecated

Author message:

not maintained

@specla/autoloader

1.0.0 • Public • Published

Specla Autoloader

npm version Build Status Coverage Status Dependency Status Standard - JavaScript Style Guide

Autoload modules and json files with ease. This packages constructs an object that reflects your folder structure and requires the files within the specified path.

Install

npm install --save @specla/autoloader

Usage

const path = require('path')
const Autoloader = require('specla-autoloader')

const modules = new Autoloader(path.resolve('./modules'))

An example of the path ./modules could look like this.

┬ modules
├── some-file.js
├── data.json
├─┬ sub-modules
  ├── other-file.js

This will create the following js object when the path is autoloaded.

const modules = {
  'some-file': require('./modules/some-file.js'),
  data: require('./modules/data.json'),
  'sub-modules': {
    'other-file': require('./modules/sub-modules/other-file.js')
  }
}

Options

const modules = new Autoloader(__dirname, {
  include: ['js', 'json'], // specifies which file types to include
  ignore: [
    'node_modules', // ignore folders
    'some-file.js' // ignore specific file
  ]
})

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i @specla/autoloader

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • kvartborg