0.1.4 • Published 7 years ago

rpr v0.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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())
0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago