Skip to content

Commit

Permalink
Merge pull request #11 from binki/fix-cleanup-call
Browse files Browse the repository at this point in the history
Call cleanup correctly (without arguments).
  • Loading branch information
benjamingr authored Jan 2, 2017
2 parents 2a404d8 + 04536f6 commit 25e8046
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ module.exports.withFile = function withFile(fn) {
cleanup = o.cleanup;
delete o.cleanup;
return fn(o);
}).finally(cleanup);
}).finally(function () {
// May not pass any arguments to cleanup() or it fails.
if (cleanup) {
cleanup();
}
});
};


Expand All @@ -44,7 +49,12 @@ module.exports.withDir = function withDir(fn) {
cleanup = o.cleanup;
delete o.cleanup;
return fn(o);
}).finally(cleanup);
}).finally(function () {
// May not pass any arguments to cleanup() or it fails.
if (cleanup) {
cleanup();
}
});
};


Expand Down

0 comments on commit 25e8046

Please sign in to comment.