Skip to content

Instantly share code, notes, and snippets.

@birjj
Last active November 28, 2016 22:44
Show Gist options
  • Save birjj/9c22fe757eea3ef594e243c681f60539 to your computer and use it in GitHub Desktop.
Save birjj/9c22fe757eea3ef594e243c681f60539 to your computer and use it in GitHub Desktop.
const readdirp = require('readdirp');
let filtered = {};
let added = {};
function filter(entry){
filtered[entry.fullPath] = true;
return true;
}
readdirp({
root: '.',
entryType: 'all',
fileFilter: filter,
directoryFilter: filter,
depth: 0,
lstat: true
}).on('data', (entry)=>{
added[entry.fullPath] = true;
}).on('end', ()=>{
var allGood = true;
for (var k in added) {
if (!filtered.hasOwnProperty(k)) {
console.log('Added file without filtering it:',k);
allGood = false;
}
}
if (allGood) {
console.log('Everything\'s good (',Object.keys(added).length,':',Object.keys(filtered).length,')');
}
});
Everything's good ( 192 : 192 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment