Skip to content

skipEmptyDirectories option #12

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

Merged
merged 3 commits into from
Dec 4, 2018
Merged

skipEmptyDirectories option #12

merged 3 commits into from
Dec 4, 2018

Conversation

amercier
Copy link
Owner

@amercier amercier commented Dec 4, 2018

options.skipEmptyDirectories (default: true)

When set to false, includes empty files lists.

# Directory structure:
level1
├── level2a (only directories)
│   └── level3
│       └── file3a
├── level2b
│   └── (empty)
└── file1a
for await (const files of filesByDirectory(['level1']/*, { skipEmptyDirectories: true }*/} )) {
  console.log(files);
}
// [ 'level1/file1a' ]
// [ 'level1/level2a/level3/file3a' ]

for await (const files of filesByDirectory(['level1'], { skipEmptyDirectories: false } )) {
  console.log(files);
}
// [ 'level1/file1a' ]
// []
// [ 'level1/level2a/level3/file3a' ]
// []

Note: this can be useful when combined with showDirectories option:

const options = { skipEmptyDirectories: false, showDirectories: true };
for await (const [directory, ...files] of filesByDirectory(['level1'], options)) {
  console.log(directory, files);
}
// level1 [ 'level1/file1a' ]
// level1/level2a []
// level1/level2a/level3 [ 'level1/level2a/level3/file3a' ]
// level1/empty-directory []

amercier added a commit that referenced this pull request Dec 4, 2018
@amercier amercier force-pushed the skip-empty-directories branch from 9e17846 to ce20011 Compare December 4, 2018 07:45
@amercier amercier merged commit c8f3de4 into master Dec 4, 2018
@amercier amercier deleted the skip-empty-directories branch December 4, 2018 07:47
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

Successfully merging this pull request may close these issues.

1 participant