0.0.1 • Published 6 years ago
@brillout/get-parent-dirname v0.0.1
Get the path of the directory of the parent module.
Usage Example
// /example/baby/index.js
const get_parent_dirname = require('@brillout/get-parent-dirname'); // npm install @brillout/get-parent-dirname
module.exports = () => {detour()};
function detour() {
// It doesn't matter how many functions are called
// between our parent module `papa` and our child module `baby`
run();
}
function run() {
// Will print the path of the directory of the `papa` module
console.log(get_parent_dirname());
}
// /example/papa/index.js
const baby = require('../baby');
baby();
Running /example/papa/index.js
will print the absolute path of the /example/papa
directory.
0.0.1
6 years ago