function _prepareTmpDirRemoveCallback(name, opts, sync) {
  const removeFunction = opts.unsafeCleanup ? rimraf : fs.rmdir.bind(fs);
  const removeFunctionSync = opts.unsafeCleanup ? FN_RIMRAF_SYNC : FN_RMDIR_SYNC;
  const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name, sync);
  const removeCallback = _prepareRemoveCallback(removeFunction, name, sync, removeCallbackSync);
  if (!opts.keep) _removeObjects.unshift(removeCallbackSync);

  return sync ? removeCallbackSync : removeCallback;
}
Prepares the callback for removal of the temporary directory.

Returns either a sync callback or a async callback depending on whether
tmpFileSync or tmpFile was called, which is expressed by the sync parameter.

@param {string} name
@param {Object} opts
@param {boolean} sync
@returns {Function} the callback
@private