`resolve` function should behave as `path.resolve`
I strongly believe appRoot.resolve should behave as path.resolve does.
It means:
- given relative path, resolve absolute path relative to the app root
- given absolute path, resolve given absolute path
Codecov Report
:exclamation: No coverage uploaded for pull request base (
master@54d06fe). Click here to learn what that means. The diff coverage is100.00%.
@@ Coverage Diff @@
## master #46 +/- ##
=========================================
Coverage ? 87.09%
=========================================
Files ? 2
Lines ? 62
Branches ? 0
=========================================
Hits ? 54
Misses ? 8
Partials ? 0
| Impacted Files | Coverage Δ | |
|---|---|---|
| lib/app-root-path.js | 100.00% <100.00%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 54d06fe...828d91a. Read the comment docs.
Hm. This makes sense. Can you explain what issue you bumped into that made you open the PR? This is a breaking change and would push us to 4.0, so I want to understand where/when it's necessary.
Sure, here is the use case.
- A dependency relay on loading certain file, let's say it's a configuration JSON file for a lib (lib uses this package as resolver)
- A dependency reads environment variable for certain variable, e.g.
{LIB}_CONFIGURATION_PATH.
Given it's a relative path (essentially means configuration file is in scope of host application directory), it should be resolved to host application root. This scenario works well.
The problem is with absolute path. A file could be outside of host application directory or inside (but referenced by absolute path). The path is not resolved correctly in this case and results in following output: {applicationRootPath}/{absolutePaht}
I fully understand this is breaking change and thus your concerns.