question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

patern match in filenames (without reading content)

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
photonstormcommented, Jan 18, 2017

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.

1reaction
ellisiumcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Read file and match with file name - Unix Stack Exchange
If there are no filenames matching that pattern, the pattern will remain unexpanded.
Read more >
How to handle files that do not contain a pattern?
The idea is to pass in a pattern and a file list from the command line. If the file name matches the pattern,...
Read more >
File name patterns - IBM
You can specify a file name pattern, using wildcard characters, to identify a file to be read by the FileInput, CDInput, and FTEInput...
Read more >
glob – Filename pattern matching - GeeksforGeeks
Glob module searches all path names looking for files matching a specified pattern according to the rules dictated by the Unix shell.
Read more >
Python Glob: Filename Pattern Matching - PYnative
Python glob module to find files and folders whose names follow a specific pattern. Search files recursively with wildcard characters.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found