rooted
v2.0.1
Published
Requiring or import modules/folders/files based on your root directory
Downloads
22
Maintainers
Readme
rooted
Requiring modules/folders/files in the right way
Installation
npm i rooted --save
Usage
////// bad
var data = require('../../../../data.json');
var helpers = require('../../../helpers');
///// good
// will build the path starting from the root directory of your application
// and require the respective file/folder/module
var rooted = require('rooted');
var data = rooted('data.json');
var helpers = rooted('helpers');
You can also get string representing the absolute path of the file/folder, passing true
as the second argument.
var rooted = require('rooted');
var data = rooted('data.json', true);
console.log(typeof data); // "string"
Tests
make test
License
MIT License © Eric Douglas