relative-filepath-from-module
v0.0.1
Published
takes and full path to a file and remove all directories before the module. SO you get back a path relative to the module
Downloads
12
Maintainers
Readme
#relative-filepath-from-module
Returns a filepath relative to the module you are in.
Usage
// file: /home/username/git/personal/relative-filepath-from-module/test/yet-another-dir/
import modulePathFromFile from 'relative-filepath-from-module'
const modulePath = modulePathFromFile(__dirname)
console.log(modulePath) // relative-filepath-from-module/test/yet-another-dir/// file: /home/username/git/personal/relative-filepath-from-module/test/yet-another-dir/testFile.js
import modulePathFromFile from 'relative-filepath-from-module'
const modulePath = modulePathFromFile(__dirname)
console.log(modulePath) // relative-filepath-from-module/test/yet-another-dir/testFile.js// file: /home/username/git/personal/relative-filepath-from-module/test/yet-another-dir
import modulePathFromFile from 'relative-filepath-from-module'
const modulePath = modulePathFromFile(__dirname)
console.log(modulePath) // relative-filepath-from-module/test/yet-another-dirShould also work on windows, but have not tested. feedback is welcomed.
