Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/samualtnorman/lib. A collection of common utilities I need. www.npmjs.com/package/@samual/lib
Something went wrong. Try again.
1234567891011121314import type { PathLike } from "fs"import { copyFile, mkdir as makeDirectory } from "fs/promises"import { dirname as getPathDirectory } from "path"
export const copyFilePersistent = (source: PathLike, destination: string, flags?: number): Promise<void> => copyFile(source, destination, flags).catch(async (error: NodeJS.ErrnoException) => { if (error.code != `ENOENT`) throw error
await makeDirectory(getPathDirectory(destination), { recursive: true })
return copyFile(source, destination, flags) })