Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

consign

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consign

Autoload your scripts.

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4K
increased by20.43%
Maintainers
1
Weekly downloads
 
Created
Source

Consign

Build Status

Autoload your scripts! the successor to express-load

Consign makes applications easier to develop with logical file separation and automatic script loading.

Consign can be used to autoload models, routes, schemas, configs, controllers, object maps... etc...

Also if you are writing scripts and just need to add some structure, check out (middleware-chain)[https://github.com/jarradseers/middleware-chain], there is a new example for this usage in the examples folder.

Usage

var consign = require('consign');

consign()
  .include('models')
  .then('controllers')
  .into(app);

// app.models.user
// app.models.company
// app.controllers.user
// app.controllers.company

Check out the examples or test folder for more!

Installation

$ npm install consign

Features

  • Autoload scripts
  • Supports order, includes and excludes
  • Made to supplement frameworks or scripts
  • Makes MVC applications easier to work with
  • Test driven
  • Fast, Light-weight with no external dependencies
  • Highly configurable

Options

The optional options object is passed in as a parameter to the main consign function.

Defaults
  consign({
    cwd: process.cwd(),
    locale: 'en-us',
    logger: console,
    verbose: true,
    extensions: [ '.js', '.json', '.node' ],
    loggingType: 'info'
  })

Logging

logger - Defaults to console, this can be switched out. verbose - On by default, set to false for no logging loggingType - Set the type of logging, defaults to info

Locale

Current supported locale (for logging output):

  • en-au
  • en-nz
  • en-us
  • fr-fr
  • pt-br
  • pl
  • zh-cn

Base Directory (cwd)

Consign will simply use a relative path from your current working directory, however sometimes you don't want heavily nested files included in the object chain, so you can set the cwd:

consign()
  .include('app') // ./app/controllers/user.js
  .into(app);

would result in:

app.app.controllers.user

so using the cwd option:

consign({cwd: 'app'})
  .include('app') // ./app/controllers/user.js
  .into(app);

would give us:

app.controllers.user

File Extensions

Defaults to an array containing .js, .json and .node, new ones are concatenated instead of replaced.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

License

MIT

Keywords

FAQs

Package last updated on 18 Jun 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc