Giter Site home page Giter Site logo

mauriciovigolo / file-matcher Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 2.0 72 KB

Search files recursively using globs, file attributes and content match.

License: MIT License

TypeScript 98.74% JavaScript 1.26%
ecmascript file filesystem nodejs search typescript

file-matcher's People

Contributors

mauriciovigolo avatar snyk-bot avatar tmrlvi avatar vindu939 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

file-matcher's Issues

TypeError: Cannot read property 'content' of undefined

If there aren't file filters it throws the following error:

TypeError: Cannot read property 'content' of undefined
    at FileMatcher.init (.../node_modules/file-matcher/lib/filematcher.js:188:28)
    at FileMatcher.find (.../node_modules/file-matcher/lib/filematcher.js:140:14)

Cannot return from wrapping function

When you wrap your file-matcher in a function, it is not possible to use return to exit that function.

See the following example. I''m expecting true or false here but get undefined instead:

var fm = require('file-matcher');

var testStrict = isStrictCodeAvailable();
// testStrict => undefined

function isStrictCodeAvailable() {
    var options = {
        path: '/../example_files/',
        fileFilter: {
            fileNamePattern: '**/*.js',
            content: /use strict/i,
        }
    };

    var fileMatcher = new fm.FileMatcher();
    fileMatcher.find(options)
        .then(function (files) {
            if(files.length > 0) {
                return true;
            } else {
                return false;
            }
        })
        .catch(function (error) {
            // ...
        });
}

There are a lot of functions that use return for jumping out of inner processes (e.g. jQuery.each()) but workarounds as this one don't work because of the asynchronous nature of fileMatcher.find(). Any ideas how to solve this?

File size limit

Do we have a default FileSize limit? And if that's the case, can it be overwritten? I'm having trouble finding the files in my React Project, for some reason the biggest files are ignored, by removing a part of the file, FileMatcher starts finding it again.

The limit seems to be around 250 lines. If the file has roughly 250 or more lines it's ignored. My configuration is as follows:

{
    path: 'src/',
    recursiveSearch: true,
    fileFilter: {
        fileNamePattern: ['**/*.tsx'],
        content: /Component/,
    },
}

The biggest Components are simply ignored.

Error: EMFILE: too many open files

I tried running file-matcher on a large project and I got the error:

   (node:12672) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: EMFILE: too many open files, open 'C:\sessions\XXXXXX.cpp'
   (node:12672) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.