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.

loading all files with certain name

See original GitHub issue

After switching to klaw, I seem to be having some issue loading only files with a certain name.

Say I want to recursively load only files named package.json. It seems like I could do something like:

var klawSync = require('klaw-sync')
var paths = klawSync('/some/dir', {ignore: '!**/package.json'})

I have also tried several other variations of the ignore pattern but nothing seems to match properly.

I am probably missing something obvious… Any ideas?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jmquigleycommented, Apr 26, 2017

It doesn’t work as I would have expected (when using a filter function). If I have the following example structure:

/tmp/dir1/dir2/file.txt

And I walked the directory at /tmp, then I would expect to see:

/tmp/dir1
/tmp/dir1/dir2
/tmp/dir1/dir2/file.txt

If I leave off the nodir: true I see this now with 2.1.0. If I add this nodir option I would have expected to see just:

/tmp/dir1/dir2/file.txt

But that is not what I get back. What I get back now is an empty array. What is happening is that once a directory is suppressed with the nodir option, then all subdirectories appear to be gone along with the files. The whole example structure above is gone, when I would have expected to still get the file.

When I do this without the filter function it works as expected, but then I lose the custom filtering.

Hope this helps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

List all files of certain type in a directory using Python
List all files of a certain type using os.walk() function ... It returns all the file names in the directory specified in the...
Read more >
Load files with certain names in R - Stack Overflow
I have thousands of files, but I only want to load some of them, those I want to load all are all named...
Read more >
Loading files with a particular string on its name - MathWorks
I would like to load the files that have SVO, MID, and IC on its name separately. Is there a way of doing...
Read more >
Python List Files in a Directory [5 Ways] - PYnative
In this article, we will see how to list all files of a directory in Python. There are multiple ways to list files...
Read more >
51 How to load only specific files from a folder in SSIS
How to load only specific files from a folder in SSISDownload the file \script used in the Video from below ...
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