@ddlees/module-root
v1.0.0
Published
Easily reference & require files from the calling module's root project directory
Downloads
4
Maintainers
Readme
module-root
module-root
will always resolve to your project's root directory making it easy to reference & require files from the calling module's root project directory. This module is intended for production use.
Install
$ npm install --save @ddlees/module-root
Usage
e.g. - test/lib/utils/foo.test.js
// Annoying
let foo = require('../../../src/lib/utils/foo');
// Better :)
let root = require('@ddlees/module-root');
let foo = root.require('src/lib/utils/foo');
e.g. - src/server/app.js
// Annoying
app.use(express.static(path.join(__dirname, '../../dist'));
// Better :)
let root = require('@ddlees/module-root');
app.use(express.static(root.path + '/dist'));