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

find-in-files

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-in-files

A simple tool to search text patterns across multiple files

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
58K
increased by2.79%
Maintainers
1
Weekly downloads
 
Created
Source

find-in-files Build Status Coverage Status

A simple tool to search text patterns across multiple files

Installation

find-in-files is a node module available via npm. You can install it with

$ npm install --save find-in-files

Usage

The module exposes a simple find function that expects three parameters.

find(pattern, directory, fileFilter)
pattern [string]

The string you want to search for.

directory [string]

The directory you want to search in.

fileFilter [regex] (optional)

A regex you can pass in to only search in files matching the filter.

var findInFiles = require('find-in-files');

The find function returns a promise which will recieve the results object. The results object contains the matches and a count of matches per file.

{
    'fileOne.txt': {
        matches: ['found string'],
        count: 1
    }
}

Example

findInFiles.find('I'm Brian, and so's my wife!', '.', '.txt$')
    .then(function(results) {
        for (var result in results) {
            var res = results[result];
            console.log(
                'found "' + res.matches[0] + '" ' + res.count
                + ' times in "' + result + '"'
            );
        }
    });

License

MIT © Philipp Nowinski

Keywords

FAQs

Package last updated on 02 Dec 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