Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

walk-back

3.0.1 • Public • Published

view on npm npm module downloads Build Status Dependency Status js-standard-style

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-19 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

install

npm i walk-back

Downloadsweekly downloads

55,704

version

3.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability