rooted

2.0.1 • Public • Published

rooted

Build Status Coverage Status npm version

NPM

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

Package Sidebar

Install

npm i rooted

Weekly Downloads

1

Version

2.0.1

License

MIT

Last publish

Collaborators

  • ericdouglas