Skip to content

Commit

Permalink
tweak to custom data function check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctalkington committed Jun 5, 2015
1 parent c0f3b86 commit 150bb3e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/core.js
Expand Up @@ -397,10 +397,12 @@ Archiver.prototype.bulk = function(mappings) {
}

try {
entryData = dataFunction ? dataFunction(entryData) : entryData;
if (dataFunction) {
entryData = dataFunction(entryData);

if (dataFunction && typeof entryData !== 'object') {
throw new Error('bulk: invalid data returned from custom function');
if (typeof entryData !== 'object') {
throw new Error('bulk: invalid data returned from custom function');
}
}
} catch(e) {
self.emit('error', e);
Expand Down Expand Up @@ -453,10 +455,12 @@ Archiver.prototype.directory = function(dirpath, destpath, data) {
entryData.stats = file.stats;

try {
entryData = dataFunction ? dataFunction(entryData) : entryData;
if (dataFunction) {
entryData = dataFunction(entryData);

if (dataFunction && typeof entryData !== 'object') {
throw new Error('directory: invalid data returned from custom function');
if (typeof entryData !== 'object') {
throw new Error('directory: invalid data returned from custom function');
}
}
} catch(e) {
self.emit('error', e);
Expand Down

0 comments on commit 150bb3e

Please sign in to comment.