1.0.6 • Published 6 years ago
@warren-bank/root-project-directory v1.0.6
root-project-directory
Description:
This is a tiny library to help when importing CommonJS modules with paths relative to the root of the project directory.
Installation:
npm install --save '@warren-bank/root-project-directory'
Usage (tl;dr):
const root = require('@warren-bank/root-project-directory').absolute_root
const module_A = require(root + '/foo/bar/baz/A')
Usage (verbose):
const root = require('@warren-bank/root-project-directory')
const absolute = root.absolute_root
const relative = root.get_relative_root(__dirname)
console.log('absolute path to root of project directory:', absolute)
console.log('relative path to root of project directory:', relative)
const module_A = require(absolute + '/foo/bar/baz/A')
const module_B = require(relative + '/foo/bar/baz/B')
Console Logs (from verbose usage example):
absolute path to root of project directory: /path/to/project
relative path to root of project directory: ../../..
Issues:
- does not play well with:
Legal:
- copyright: Warren Bank
- license: GPLv2