Skip to content

byronogis/rrpf

Repository files navigation

rrpf

NPM version

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'

rrpf('./path/to/file/foo.*')
// 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

Sponsors

License

MIT License © 2022 Liam Shi

About

Reliable relative path of the file

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published