climb-lookup
v1.0.0
Published
a lookup climbing recursively file like a require.
Downloads
84
Maintainers
Readme
Climb lookup
a lookup climbing recursively file like a require.
Usage
npm install climb-lookup --save
import {lookup, lookupSync, getPaths} from 'climb-lookup';
console.log(lookupSync('package.json')); // /path/to/package.json
Why?
It may fail to read the configuration file due to process.cwd()
.
cd my-project
tree . -L 1
# .
# ├── src
# ├── test
# └── package.json
node -e "require(process.cwd()+'/package.json')" # ok
cd test
node -e "require(process.cwd()+'/package.json')" # Error: Cannot find module './test/package.json'
climb-lookup
is lookup climbing recursively file, like a require
.
cd my-project
tree . -L 1
# .
# ├── src
# ├── test
# └── package.json
node -e "require(require('climb-lookup').lookupSync('package.json'))" # ok
cd test
node -e "require(require('climb-lookup').lookupSync('package.json'))" # ok
Test
git clone https://github.com/59naga/climb-lookup.git
cd climb-lookup
npm install
npm test