0.0.3 • Published 7 years ago
find-dir-path v0.0.3
find-dir-path
Find a directory by walking up parent directories
based on sindresorhus/find-up, project template egoist/template-nm
Install
yarn add find-dir-path
Usage
/
└── Users
└── zcong1993
├── unicorn.png
└── foo
└── bar
└── foo(file) ├── baz
└── example.js
// example.js
const findDirPath = require('find-dir-path')
findDirPath('foo')
.then(path => {
console.log(path)
//=> '/Users/zcong1993/'
})
findDirPath.sync('foo')
//=> '/Users/zcong1993/'
API
findDirPath(name, options)
Returns a Promise for either the dirpath or null if it could be found.
findDirPath.sync(name, options)
Returns the first filepath found (by respecting the order) or null.
name
Type: string
Name of the directory to find.
options
cwd
Type: string
Default: process.cwd()
Directory to start from.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
find-dir-path © zcong1993, Released under the MIT License. Authored and maintained by zcong1993 with help from contributors (list).
github.com/zcong1993 · GitHub @zcong1993