npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-find-folder

v0.1.32

Published

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

Downloads

11,008

Readme

find-folder

Gitter codebeat badge Build status Build Status Project Dependencies Project devDependencies Issues Closed In... Pull Request Closed In... MIT LICENSE NPM · downloads, rank and stars

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 library to do some matching work.

Usage

First, you should know the Folder structure for demo below.

Install

how to install

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

Code details,

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:

/*
  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:

/*
  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,

...

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,

...

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 board! I use Trello to manage the plan of this project. And we can discuss a lot through the related board! Of course we can use Gitter 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 or Trello. I will be very gratefull!

I found a bug!

If you found a repeatable bug, and tips from Usage section didn't help, then be sure to search existing issues 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, then learn be social with Github and how to pull the repo on node-find-folder.

Contact info

LICENSE

See also LICENSE .