rootmodule

0.0.3 • Public • Published

rootmodule

Find root module with folder and package.json.

This module is very useful to support/find additonal configurations, plugins & extensions for your libraries.

For example, if you have a node module called awesome-module and want to allow your clients to set configuration parameters. Two most common ways of doing this is via

  1. custom configuration file - say .awesomerc in the projects root folder
  2. a custom entry in root package.json file

babel, eslint and other libraries follow this pattern.

To simply load the root package.json:

var rootModule = require('root-module'); 
var m = rootModule();
var packageJson = require(m.packageFile);

To locate the custom configuration file:

var rootModule = require('root-module'); 
var m = rootModule();
var awesomeConfig = m.findFile('.awesomerc');

Installation

Install via npm

$ npm install rootmodule --save

Usage

var rootModule = require('rootmodule'); 
var m = rootModule();

console.log(m.module);
console.log(m.folder);
console.log(m.packageFile);

var myConfig = m.findFile('my-config.json');

License

MIT

/rootmodule/

    Package Sidebar

    Install

    npm i rootmodule

    Weekly Downloads

    3

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    4.63 kB

    Total Files

    4

    Last publish

    Collaborators

    • palanik