0.1.4 • Published 8 years ago
rpr v0.1.4
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())