You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
311 B
TypeScript
13 lines
311 B
TypeScript
import { move } from 'fs-extra/esm'
|
|||
import { rename } from 'fs/promises'
|
|||
|
|||
export async function tryAtomicMove (src: string, destination: string) {
|
|||
try {
|
|||
await rename(src, destination)
|
|||
} catch (err) {
|
|||
if (err?.code !== 'EXDEV') throw err
|
|||
|
|||
return move(src, destination, { overwrite: true })
|
|||
}
|
|||
}
|