rrpf
Reliable relative path of the file
Why
When i use npx
to execute a '.js' file that contains references to files in relative path, file had been looking for based on the path where the npx
is executed.
That's certainly not what I wanted, the path that based on '.js' file is what I expected.
Install
npm i rrpf
Usage
// module
import rrpf from 'rrpf'
// or commonjs
const rrpf = require('rrpf')
rrpf('./path/to/file/foo.*')
Example
|-- project
|-- a.js
|-- b.js
// a.js
import rrpf from 'rrpf'
rrpf('./b.js') // /path/to/project/b.js