Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patern match in filenames (without reading content) #38

Open
QAscoop opened this issue Oct 6, 2016 · 5 comments
Open

patern match in filenames (without reading content) #38

QAscoop opened this issue Oct 6, 2016 · 5 comments

Comments

@QAscoop
Copy link

QAscoop commented Oct 6, 2016

The pattern matching works very well with "dir.readFiles()" but couldn't figure it out for dir.files(). The exclude and include examples do not seem to be supporting glob-like matching or regex. Here is a sample to illustrate the issue:

dir.files(myDir, { match: /pattern/ }, function(err, files) {
    if (err) throw err;
    console.log("files)
  });

When executed, this throws a callback error:

node_modules/node-dir/lib/paths.js:25
            callback(null, results);
            ^

TypeError: callback is not a function
    at done (..node_modules/node-dir/lib/paths.js:25:13)
    at ..node_modules/node-dir/lib/paths.js:53:37
    at done (..node_modules/node-dir/lib/paths.js:25:13)
    at ..node_modules/node-dir/lib/paths.js:60:33
    at FSReqWrap.oncomplete (fs.js:82:15)
@photonstorm
Copy link

I hit this same error today, but it's nothing to do with pattern matching - dir.files just doesn't accept an object as the second argument. I was trying with:

var files = dir.files(__dirname, { sync: true });

.. and it fails in exactly the same place, because the signature for files is expecting something different. Looking at the code this is a problem in v0.1.16 which is the most recent version published to npm, but looks fixed in v0.1.17 which is in this repo, but not on npm.

@ashraffayad
Copy link

ashraffayad commented Jan 31, 2017

I had the same issue today.
I manually copied the content of the /lib folder from this repo into the /node_modules/node-dir/lib
Now it works fine.
Thanks @photonstorm

@ellisium
Copy link

ellisium commented Apr 24, 2017

Latest npm version is 0.1.16 while git latest version is 0.1.17.
Please update it to let us use npm install

@Mbarley
Copy link

Mbarley commented Jul 11, 2017

Any solution for @GroovyQA original question? That is, using regex with files()?

@InanisOmnia
Copy link

Any update? I'd still very much lilke to have pattern matching without having to read all the files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants