https://github.com/ericdouglas/rooted
:open_file_folder: Require modules/folders/files in the right way
https://github.com/ericdouglas/rooted
Last synced: about 1 year ago
JSON representation
:open_file_folder: Require modules/folders/files in the right way
- Host: GitHub
- URL: https://github.com/ericdouglas/rooted
- Owner: ericdouglas
- Created: 2015-07-17T17:40:09.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-02T11:37:32.000Z (over 10 years ago)
- Last Synced: 2025-04-28T01:16:48.755Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 191 KB
- Stars: 22
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rooted
[](https://travis-ci.org/ericdouglas/rooted)
[](https://coveralls.io/github/ericdouglas/rooted?branch=master)
[](http://badge.fury.io/js/rooted)
[](https://nodei.co/npm/rooted/)
Requiring modules/folders/files in the right way
## Installation
```
npm i rooted --save
```
## Usage
```js
////// 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.
```js
var rooted = require('rooted');
var data = rooted('data.json', true);
console.log(typeof data); // "string"
```
## Tests
```
make test
```
## License
[MIT License](http://ericdouglas.mit-license.org/) © Eric Douglas