Skip to content

Fix incorrect documented usage#9

Merged
phated merged 1 commit into
gulpjs:masterfrom
s100:patch-1
Apr 20, 2022
Merged

Fix incorrect documented usage#9
phated merged 1 commit into
gulpjs:masterfrom
s100:patch-1

Conversation

@s100

@s100 s100 commented Apr 20, 2022

Copy link
Copy Markdown
Contributor

The documented example usage of this package is backwards. Using the example code as it is currently, here's what happens:

mkdir i-should-be-empty
touch i-should-be-empty/Thumbs.db
touch i-should-be-empty/.DS_Store
const emptyDir = require('empty-dir');

function filter(filepath) {
  return !/(Thumbs\.db|\.DS_Store)$/i.test(filepath);
}

console.log(emptyDir.sync('./i-should-be-empty', filter));

This prints:

false

when clearly this directory should be considered "empty" due to containing nothing but unwanted garbage files.

Compare with the filter used during unit testing, which is correct:

empty-dir/test/index.js

Lines 13 to 15 in 4817e65

function isGarbageFile(filename) {
return /(?:Thumbs\.db|\.DS_Store)$/i.test(filename);
}

@phated phated left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! Thanks!

@phated phated merged commit 2f34c99 into gulpjs:master Apr 20, 2022
@s100 s100 deleted the patch-1 branch May 31, 2022 14:06
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.

2 participants