0.0.3 • Published 7 years ago

find-dir-path v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

find-dir-path

NPM version NPM downloads Build Status

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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. 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