lazy-dir

Lazy define current directory

Usage no npm install needed!

<script type="module">
  import lazyDir from 'https://cdn.skypack.dev/lazy-dir';
</script>

README

lazy-dir

Lazy define current directory

Travis CI node npm PRs


Install

$ npm install lazy-dir

Usage

const dir = require('lazy-dir')(module);

console.log(dir.here());
//=> /path/to/project/awesome

console.log(dir.here('foo', 'bar'));
//=> /path/to/project/awesome/foo/bar

API

require('lazy-dir')(module);

  • Params:
    • module: <NodeJS.Module> (required)
  • Returns: <object>

.pwd([...paths])

  • Params:
    • ...paths: <string[]> (optional)
  • Returns: <string>
  • Example:
    dir.pwd('a', 'b', 'c'); // eq: path.resolve(process.cwd(), 'a', 'b', 'c')
    

.here([...paths])

  • Params:
    • ...paths: <string[]> (optional)
  • Returns: <string>
  • Example:
    dir.here('a', 'b', 'c'); // eq: path.resolve(__dirname, 'a', 'b', 'c')
    

License

MIT © Guntur Poetra