path-here

A simple module to get the path with __dirname

Usage no npm install needed!

<script type="module">
  import pathHere from 'https://cdn.skypack.dev/path-here';
</script>

README

path-here

Status: npm version npm downloads Build Status Code Coverage

This micro-lib will take your code from this:

var path = require('path');
var srcDirectory = path.resolve('src');

to this:

var here = require('path-here');
var srcDirectory = here('src');

Note: This is actually not all that useful. Originally when I made this I thought it was doing something it wasn't. However, something more useful that it allows you to do (and the reason I haven't deprecated it) is this:

var here = require('path-here');
var there = here.dir('~/Developer/starwars-names');
var starWarsNamesSrc = there('src');

Examples

var here = require('path-here');
var srcDir = here('src');
var somePath = here('some/path');
var somePathWithMultipleParams = here('some', 'path'); // <-- same result as previous
var withTrailingSlash = here('src/'); // <-- result has a trailing slash
var withPrefixSlash = here('/src'); // <-- same as here('src');

// specify a different root other than process.cwd()
var there = here.dir('/usr');
var bin = there('bin');

Other info

LICENSE -> MIT