delete-empty
delete-empty copied to clipboard
Callback can be called twice
https://github.com/jonschlinkert/delete-empty/blob/6ae34547663e6845c3c98b184c606fa90ef79c0a/index.js#L60-L61
If cb() throws an error, it will be called again within the error object.
Can you provide some example code with a case where this is causing a bug?
If so, a PR with a fix for the bug will be welcome.
const deleteEmpty = require("delete-empty");
const path = ".";
const onDone = (err, result) => {
console.log("onDone", err, result);
throw new Error("error in onDone");
};
try {
deleteEmpty(path, onDone);
} catch (err) {
console.log("err", err);
}
onDone is called twice. REPL
The correct code should be:
.then(
res => cb(null, res),
err => cb(err, null) // or just `cb`
)