Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
destpath = '';
} else if (typeof destpath !== 'string'){
destpath = dirpath;
}
var dataFunction = false;
if (typeof data === 'function') {
dataFunction = data;
data = {};
} else if (typeof data !== 'object') {
data = {};
}
var self = this;
util.walkdir(dirpath, function(err, results) {
if (err) {
self.emit('error', err);
} else {
results.forEach(function(file) {
var entryData = _.extend({}, data);
entryData.name = file.relative;
entryData.prefix = destpath;
entryData.stats = file.stats;
try {
if (dataFunction) {
entryData = dataFunction(entryData);
if (typeof entryData !== 'object') {
throw new Error('directory: invalid data returned from custom function');
}