createAtomicWriteStream = async (filename) => {
  const parentDir = path.dirname(filename)
  await access(parentDir).catch(() => mkdir(parentDir, {recursive: true}))

  const tmp = await createTmpFile(filename)
  const fileStream = fsCreateWriteStream(tmp, {encoding: 'binary', flush: true})

  return wrapRenameStream(fileStream, tmp, filename)
}
@param {string} filename
@returns {Promise<Transform>}