# recursive-file-walker

> recursively look over all the files and sub directories from a starting directory

Latest version **3.1.3** (published 2022-03-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install recursive-file-walker
pnpm add recursive-file-walker
yarn add recursive-file-walker
bun add recursive-file-walker
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.3 |
| Published | 2022-03-07 |
| First published | 2021-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Paul Browne |
| Maintainers | paul-browne |

## Links

- npm: https://www.npmjs.com/package/recursive-file-walker
- Repository: https://github.com/Paul-Browne/npm-file-walker
- Homepage: https://github.com/Paul-Browne/npm-file-walker#readme
- Issues: https://github.com/Paul-Browne/npm-file-walker/issues
- npm.io page: https://npm.io/package/recursive-file-walker

## Dependencies (1)

- [stamptime](https://npm.io/package/stamptime.md) ^3.0.4

## Recent versions

- 3.1.3 (latest) — 2022-03-07
- 3.1.2 — 2022-03-07
- 3.1.1 — 2022-03-07
- 3.1.0 — 2021-10-21
- 3.0.4 — 2021-10-20
- 3.0.3 — 2021-10-20
- 3.0.2 — 2021-10-20
- 3.0.1 — 2021-10-20
- 3.0.0 — 2021-10-20
- 2.0.1 — 2021-10-19
- 2.0.0 — 2021-10-18
- 1.1.1 — 2021-03-11
- 1.1.0 — 2021-03-11
- 1.0.9 — 2021-03-11
- 1.0.8 — 2021-02-17
- … 7 more at https://npm.io/package/recursive-file-walker/versions

## README

# recursive-file-walker
recursively look over all the files and sub directories from a starting directory

### usage

`npm i recursive-file-walker`

or 

`npm i -D recursive-file-walker`


```js
import fileWalker from "recursive-file-walker";

const response = await fileWalker({
	id: 789,                           // pass an id, if you are using more than one fileWalker function (optional)
  entry: "path/to/start/directory",  // where to start the recursive file walker
  ignoreFiles: ["*.js", "foo/*.js"], // TODO will ignore files (string), or array of file types/paths
	ignoreDirectories: ["bar", "foo"], // TODO will ignore a directory (string), or array of directories
	ignoreDotFiles: true,              // will ignore dotfiles, default:true
  ignoreDotDirectories: true,        // TODO will ignore dotDirectories, default:true 
	readFiles: "modified",             // "true" - all files, "false" - no files, "modified" will only read the file if the contents have been changed, default:false
  flatten: false                    // if true, will flatten the response
  sort: "asc"                        // TODO - sort by depth if flat asc or desc
});

// when finished, array passed with all file and directory details
// will inc. contents if readFile:true or if readFile:"modified" and contents have changed
console.log(response);
```

example response for a file. `contents` will be undefined if `readFile: false`.
`modified` will be `true` if the contents have changed, or if the file was created since the last walk (since the last time the function was called)

```js
[
  {
    stats: Stats {
      dev: 16777220,
      mode: 33188,
      nlink: 1,
      uid: 501,
      gid: 20,
      rdev: 0,
      blksize: 4096,
      ino: 59344407,
      size: 4214700,
      blocks: 8320,
      atimeMs: 1613435111889.6147,
      mtimeMs: 1613432214420.2336,
      ctimeMs: 1613432214420.2336,
      birthtimeMs: 1613431128666.037,
      atime: 2021-02-16T00:25:11.890Z,
      mtime: 2021-02-15T23:36:54.420Z,
      ctime: 2021-02-15T23:36:54.420Z,
      birthtime: 2021-02-15T23:18:48.666Z
    },
    path: 'test/index.txt',
    name: 'index.txt',
    contents: <Buffer 4c 6f 72 65 6d 20 69 70 73 75 6d 20 64 6f 6c 6f 72 20 73 69 74 20 61 6d 65 74 2c 20 63 6f 6e 73 65 63 74 65 74 75 72 20 61 64 69 70 69 73 69 63 69 6e ... 4214650 more bytes>,
    modified: true,
    depth: 0
  },
  [],  /* ignored directory */
  {},  /* ignored file */
  [    /* sub directory */
    {...},
    {...},
    [
      {...},
      {...},
      {...}
    ],
    {...}
  ]
]
```

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