# node-find-folder

> Walk a directory tree in node.js. Use just the name to find the folder(s) you want, rather than through given path(s).

Latest version **0.1.32** (published 2017-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-find-folder
pnpm add node-find-folder
yarn add node-find-folder
bun add node-find-folder
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.32 |
| Published | 2017-05-26 |
| First published | 2014-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.8.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | itonyyo |
| Keywords | node-find-folder, gulp-find-folder, grunt-find-folder, find just the folders, match folders, search folders, traversal folders, find directory, search directory, traversal directory, walk a directory tree, scan a directory tree, search a directory tree, get paths of specific folders, scan dir, scan directory, glob-find-folders, minimatch, glob, path, fs, gulp |

## Links

- npm: https://www.npmjs.com/package/node-find-folder
- Repository: https://github.com/iTonyYo/node-find-folder
- Issues: https://github.com/iTonyYo/node-find-folder/issues
- npm.io page: https://npm.io/package/node-find-folder

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^7.1.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [is-file](https://npm.io/package/is-file.md) ^1.0.0
- [is-directory](https://npm.io/package/is-directory.md) ^0.3.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 0.1.32 (latest) — 2017-05-26
- 0.1.31 — 2017-05-26
- 0.1.30 — 2017-05-09
- 0.1.29 — 2017-02-28
- 0.1.28 — 2017-01-20
- 0.1.27 — 2016-09-18
- 0.1.26 — 2016-09-18
- 0.1.25 — 2016-02-11
- 0.1.21 — 2015-12-15
- 0.1.14 — 2015-10-09
- 0.1.13 — 2015-06-08
- 0.1.12 — 2015-03-23
- 0.1.11 — 2015-01-27
- 0.1.10 — 2015-01-15
- 0.1.9 — 2015-01-07
- … 8 more at https://npm.io/package/node-find-folder/versions

## README

find-folder
===========

[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iTonyYo/node-find-folder?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![codebeat badge](https://codebeat.co/badges/daedcdf2-69e4-4958-b394-adc84c85776f)](https://codebeat.co/projects/github-com-itonyyo-node-find-folder-develop) [![Build status](https://ci.appveyor.com/api/projects/status/tgg5rob05g94mao9/branch/master?svg=true)](https://ci.appveyor.com/project/iTonyYo/node-find-folder/branch/master) [![Build Status](https://travis-ci.org/iTonyYo/node-find-folder.svg)](https://travis-ci.org/iTonyYo/node-find-folder) [![Project Dependencies](https://david-dm.org/iTonyYo/node-find-folder.png)](https://david-dm.org/iTonyYo/node-find-folder '点击 · Click') [![Project devDependencies](https://david-dm.org/iTonyYo/node-find-folder/dev-status.png)](https://david-dm.org/iTonyYo/node-find-folder#info=devDependencies '点击 · Click') [![Issues Closed In...](http://img.shields.io/badge/Issues%20Closed%20In-Not%20Available-red.svg?style=flat)](http://issuestats.com/github/iTonyYo/node-find-folder '点击 · Click') [![Pull Request Closed In...](http://img.shields.io/badge/Pull%20Requests%20Closed%20In-5%20minutes-brightgreen.svg?style=flat)](http://issuestats.com/github/iTonyYo/node-find-folder '点击 · Click') [![MIT LICENSE](https://camo.githubusercontent.com/377eda57da4e5aff0480df11e5a0ada0b5d95903/687474703a2f2f696d672e736869656c64732e696f2f6e706d2f6c2f69732d6f626a6563742e737667)](https://github.com/iTonyYo/WSK_IMAGE/blob/master/LICENSE '点击 · Click') ![NPM · downloads, rank and stars](https://nodei.co/npm/node-find-folder.png?downloads=true&downloadRank=true&stars=true)



Primer
------

Walk a directory tree in node.js. Use **just the name** to find the folder(s) you want, rather than through given path(s)  - To search the targeted directory(s) you want in the whole project，return array type result. Then, you can do anything you want with the result! For batch operations which according to the directory(s).

It uses the `glob` library to do some matching work.



Primer
------

Walk a directory tree in node.js. Use **just the name** to find the folder(s), rather than through given path(s)  - To search the targeted directory(s) you want in the whole project，return array type result. Then, you can do anything you want with the result! For batch operations which according to the directory(s).

It uses the [`glob`](https://www.npmjs.com/package/glob) library to do some matching work.



Usage
-----

First, you should know the [***Folder structure for demo below***](https://gist.github.com/iTonyYo/8df470481bdb7f4a0e4d '点击 · Click').

**Install**

![how to install](https://nodei.co/npm/node-find-folder.png?mini=true)

You can use `--save-dev` param after the command above to save `node-find-folder` to `package.json`

**Code details,**

```js
var ff, ff_result;

ff = require('node-find-folder');

/*
  if '1' is under 'dev/image/ui_icon_social_64px',
  and '1' is folder,
  then output will be ['dev/image/ui_icon_social_64px/1'].
*/
ff_result = new ff('1');
```

**Exist the same folder under some directories! But I just need one of them! How should I do?**

A: You can do like this:

```js
/*
  output: ['dev/image/ui_icon_social_32px/grey']
  not: [
    'dev/image/ui_icon_keyamoon_32px/grey',
    'dev/image/ui_icon_social_32px/grey'
    ]
*/
ff_result = new ff('grey', {
  ignore: ['dev/image/ui_icon_keyamoon_32px/grey']
});
```

**I don't want to traverse folders like `.git`, `node_modules` and `dest` which are in the root of project! Maybe more... How should I do?**

A: By default, this module will ignore `.git`, `node_modules` two folders. So you can just do like this:

```js
/*
  the ".git", "node_modules" and "dest" folders
  will not be traversed in this way.
*/
ff_result = new ff('grey', {
  nottraversal: ['dest']
});
```

***Want more features? Let's improve this module togethor!***



Code without `node-find-folder`,
--------------------------------

```js
...

var order, cln_prefix;

// the name of folder
order      = [
  'ui_icon_keyamoon_16px',
  'ui_icon_keyamoon_32px',
  'ui_icon_social_32px'
];
cln_prefix = 'clean-';

order.forEach((the) => {
	gulp.task(cln_prefix + the, () => {
		fs.readdir(process.cwd(), (err, files) => {
			let deal = (_item, _index, _array) => {
				if (isDir(_item)) {
					if (_item === the) {
						del(_item + '/*');
					}
				}
			};
			files.forEach(deal);
		});
	});
});

gulp.task('clean', order.map(function (the) {
	return cln_prefix + the;
}));

...
```
The code above is too much... and not flexible...



Code with `node-find-folder`,
-----------------------------

```js
...

var ff, order, cln_prefix;

ff = require('node-find-folder');

// the name of folder
order      = [
  'ui_icon_keyamoon_16px',
  'ui_icon_keyamoon_32px',
  'ui_icon_social_32px'
];
cln_prefix = 'clean-';

order.forEach((the) => {
	gulp.task(cln_prefix + the, () => {
		let ff_result = new ff(the);
		ff_result.forEach((_item, _index, _array) => {
			del(_item + '/*');
		});
	});
});

gulp.task('clean', order.map((the) => {
	return cln_prefix + the;
}));

...
```
Code is simple, flexible and well-understood! The most important thing is that you can focus on your operation.



API
------

#### getFolders(folderName, [options])

Return array type data which contain the path(s) of matched folder(s).

#### Options

+ `nottraversal`, **`Array` type**; **default value is `['.git', 'node_modules']`**; for top-level directories which need to be ignored.

+ `ignore`, **`Array` type**; **default value is `[]`**; for specific path to folder(s) which need to be ignored.



Helping `node-find-folder`
--------------------------

#### What's `node-find-folder` working on next?

You can check the plan of development in my related [*Trello*](https://trello.com/b/Hc2tSxlR '点击 · Click') board! I use [*Trello*](https://trello.com/ '点击 · Click') to manage the plan of this project. And we can discuss a lot through the related board! Of course we can use [*Gitter*](https://gitter.im/iTonyYo/node-find-folder '点击 · Click') to discuss, too! You can choose your favorite kind of communication form!

#### My requirement is not met!

A person's strength is limited, I will ignore something... Or, I just did not get the idea what you think... If you'd like to help to improve the project, whelcome you to present your ideas on [*Gitter*](https://gitter.im/iTonyYo/node-find-folder '点击 · Click') or [*Trello*](https://trello.com/b/Hc2tSxlR '点击 · Click'). I will be very gratefull!

#### I found a bug!

If you found a repeatable bug, and tips from [*Usage*](https://github.com/iTonyYo/node-find-folder#usage '点击 · Click') section didn't help, then be sure to [*search existing issues*](https://github.com/iTonyYo/node-find-folder/issues '点击 · Click') first. If there's no content is similar with the problem you found, welcome you to create a new issue you found!

#### I want to help with the code!

Awesome! I use Github to managed code. So there are lots of ways you can help. First read [*CONTRIBUTING.md*](https://github.com/iTonyYo/node-find-folder/blob/master/doc/CONTRIBUTION.md '点击 · Click'), then learn [*be social with Github*](https://help.github.com/articles/be-social/) and [*how to pull the repo*](https://help.github.com/articles/creating-a-pull-request/ '点击 · Click') on `node-find-folder`.



Contact info
------------

+ **Twitter:** [@iTonyYo](https://twitter.com/iTonyYo)

+ **Instagram:** [@iTonyYo](http://instagram.com/itonyyo/)

+ **Medium:** [@iTonyYo](https://medium.com/@itonyyo)



LICENSE
-------

See also [*LICENSE*](https://github.com/iTonyYo/node-find-folder/blob/master/LICENSE '点击 · Click') .

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