Skip to content
Find files by matching content
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
docconfig
docs
src
test
.gitignore
.npmignore
.npmrc
.travis.yml
CONTRIBUTING.md
README.md
docs.md
extensions.json
index.js
issue_template.md
package.json
tsconfig.json
tslint.json

README.md

FileSniffer

NPM downloads Build Status Coverage Status github-issues

Find files by matching contents

Installation

npm install --save filesniffer

Usage

// Searches for `someString` in `/tmp/test.txt`, returning all matches as an array:
const matches = await FileSniffer.create()
  .path('/tmp/test.txt')
  .collect(asArray())
  .find('someString');

  console.log(matches); // array of matching lines
// Use events for searching large files: 
const sniffer = await FileSniffer.create();

// register event handlers
sniffer.on('match', (filename, line) => {
  console.log(`Matching line ${line} found in ${filename}`);
});

sniffer.on('end', (filenames) => {
  console.log(`All files that match: ${filenames}`);
});

// start search
sniffer
  .path('/tmp')
  .find('some string');

Documentation

For more examples and API details, see API documentation

Test

npm test

Test Coverage

To generate a test coverage report:

npm run coverage

Contributing

See contributing guidelines

You can’t perform that action at this time.