All Projects → 75lb → walk-back

75lb / walk-back

Licence: MIT license
Walk up the directory tree until a specified path is found.

Programming Languages

javascript
184084 projects - #8 most used programming language

view on npm npm module downloads Gihub repo dependents Gihub package dependents Build Status js-standard-style

walk-back

walk-back

Walk up the directory tree until the specified path is found.

Example

const walkBack = require('walk-back')

walkBack(startAt, lookingFor) ⇒ string

Returns an absolute file path (if found) else null.

Kind: Exported function

Param Type Description
startAt string the directory to start in
lookingFor string the path we're looking for

Example

> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'package.json')
'/Users/lloyd/Documents/75lb/walk-back/package.json'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '75lb')
'/Users/lloyd/Documents/75lb'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('.', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'non-existent.file')
null

© 2015-21 Lloyd Brookes <[email protected]>.

Tested by test-runner. Documented by jsdoc-to-markdown.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].