0.0.3 • Published 6 years ago

rootmodule v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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