# walk-up

> a module to walk upwards in a directory structure to find the first path that contains a file or folder

Latest version **1.0.2** (published 2017-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install walk-up
pnpm add walk-up
yarn add walk-up
bun add walk-up
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-04-09 |
| First published | 2017-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Glen Keane |
| Maintainers | thekemkid |
| Keywords | walk, require, fs, path |

## Links

- npm: https://www.npmjs.com/package/walk-up
- Repository: https://github.com/thekemkid/walk-up
- Homepage: https://github.com/thekemkid/walk-up#readme
- Issues: https://github.com/thekemkid/walk-up/issues
- npm.io page: https://npm.io/package/walk-up

## Dependencies (1)

- [stack-trace](https://npm.io/package/stack-trace.md) 0.0.9

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-04-09
- 1.0.1 — 2017-04-09
- 1.0.0 — 2017-04-09

## README

# Walk-up

a module to walk upwards in a directory structure to find the first path that contains a file or folder, similar to how `require('dependency')' finds the node_modules folder in parent paths.

## Usage:

given a file structure like so:
```
$ tree -L 2
.
├── index.js
├── node_modules
├── package.json
├── readme.md
└── test
    └── test.js

```

and you run the following in test.js:

```js
const walkup = require('walk-up')
walkup(__dirname, 'node_modules', (err, result) => {
  result.found === true
  // the path would be absolute, just showing relative for example sake
  result.path == '../' // the parent folder path which holds the node_modules
})
```

## API:

```
walkup(startPath, toFind, callback)
```

- `startPath`: a string representing the path at which to start the search. Can be either an absolute or relative path, however, an absolute path is preferred for performance reasons.
- `toFind`: a string which is the sub-path to find. For example. If you wanted to find the 'node\_modules' folder, you would supply that string, but if you wanted the 'node\_modules' that contained the dependency 'express' you would supply the string 'node_modules/express'.
- `callback`: a callback to be called when the path has been found, or when the root directory 'e.g. `/` on *nix-like OSes' has been searched, and nothing was found. Takes two params, an `error`, and the `result`.

The callback takes two parameters.
- `error`: an error, if there was any encountered
- `result`: an object with two properties, `found`, a boolean which will be true if the sub-path was found, and `path` a string which is the path it was found at.

## License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/walk-up · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
