Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/tmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCall
} else {
return removeFunction(fileOrDirName, next || function() {});
}
} else if (!sync) {
next();
}
};
}
Expand Down
28 changes: 28 additions & 0 deletions test/inband-standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ function inbandStandardTests(testOpts, opts, isFile, beforeHook, sync = false) {
throw err;
}
}.bind(topic));

it('should support removeCallback called multiple times', function () {
try {
this.topic.removeCallback();
} catch (err) {
// important: remove file or dir unconditionally
try {
fs.rmSync(this.topic.name, { recursive: true });
} catch (_ignored) {
// ignore
}
throw err;
}
}.bind(topic));
} else {
it('should have a working removeCallback', function (done) {
const self = this;
Expand All @@ -106,6 +120,20 @@ function inbandStandardTests(testOpts, opts, isFile, beforeHook, sync = false) {
done();
});
}.bind(topic));

it('should support removeCallback called multiple times', function (done) {
const self = this;
this.topic.removeCallback(function (err) {
if (err) return done(err);
try {
assertions.assertDoesNotExist(self.topic.name);
} catch (err) {
fs.rmSync(self.topic.name, { recursive: true });
return done(err);
}
done();
});
}.bind(topic));
}
};
}