Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

findit

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

findit

walk a directory tree recursively with events

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
103K
decreased by-5.31%
Maintainers
1
Weekly downloads
 
Created
Source

findit

Recursively walk directory trees. Think /usr/bin/find.

build status

example

var finder = require('findit')(process.argv[2] || '.');
var path = require('path');

finder.on('directory', function (dir, stat, stop) {
    var base = path.basename(dir);
    if (base === '.git' || base === 'node_modules') stop()
    else console.log(dir + '/')
});

finder.on('file', function (file, stat) {
    console.log(file);
});

finder.on('link', function (link, stat) {
    console.log(link);
});

methods

var find = require('findit')

var finder = find(basedir, opts)

Return an event emitter finder that performs a recursive walk starting at basedir.

If you set opts.followSymlinks, symlinks will be followed. Otherwise, a 'link' event will fire but symlinked directories will not be walked.

If basedir is actually a non-directory regular file, findit emits a single "file" event for it then emits "end".

You can optionally specify a custom fs implementation with opts.fs. opts.fs should implement:

  • opts.fs.readdir(dir, cb)
  • opts.fs.lstat(dir, cb)
  • opts.fs.readlink(dir, cb) - optional if your stat objects from opts.fs.lstat never return true for stat.isSymbolicLink()

finder.stop()

Stop the traversal. A "stop" event will fire and then no more events will fire.

events

finder.on('path', function (file, stat) {})

For each file, directory, and symlink file, this event fires.

finder.on('file', function (file, stat) {})

For each file, this event fires.

finder.on('directory', function (dir, stat, stop) {})

For each directory, this event fires with the path dir.

Your callback may call stop() on the first tick to tell findit to stop walking the current directory.

For each symlink, this event fires.

Every time a symlink is read when opts.followSymlinks is on, this event fires.

finder.on('end', function () {})

When the recursive walk is complete unless finder.stop() was called, this event fires.

finder.on('stop', function () {})

When finder.stop() is called, this event fires.

install

With npm do:

npm install findit

license

MIT

Keywords

FAQs

Package last updated on 06 May 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc