rootmodule
v0.0.3
Published
Find root module with path and package.json
Downloads
22
Maintainers
Readme
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
- custom configuration file - say
.awesomerc
in the projects root folder - 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');