walk-back
Walk up the directory tree until the specified path is found.
Last updated 6 years ago by 75lb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install walk-back 
SYNC missed versions from official npm registry.

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 <75pound@gmail.com>.

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

Current Tags

  • 5.1.1                                ...           latest (3 months ago)

13 Versions

  • 5.1.1                                ...           3 months ago
  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.1                                ...           9 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE