rpr

rpr

Resolves '~/...' to a project root

Showing:

Popularity

Downloads/wk

0

GitHub Stars

0

Maintenance

Last Commit

4yrs ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

RPR (Resolve Project Root)

Resolves '~/...' to a project root

This little utility modifies the built-in path.resolve(...) function so that you can resolve paths relative to a project root. Because require(...) uses path.resolve(...), this also modifies the behvaior of require(...).

Example

./utils.js


module.exports.square = (x) => {
  return x * x;
}

./index.js

require('rpr')(__dirname);

const custom = require('~/path/file.js');

custom();

./path/file.js

const { square } = require('~/utils.js');

module.exports = () => {
  console.log( square(2) );  
}

API

rpr([directory])

  • directory {String} a path to set as the project directory (Default: process.cwd())

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100