13 lines
330 B
TypeScript
13 lines
330 B
TypeScript
import { access } from 'node:fs/promises';
|
|
import { setTimeout } from 'node:timers/promises';
|
|
|
|
export async function waitTillWrittenToDisk(path: string): Promise<void> {
|
|
try {
|
|
await access(path);
|
|
return undefined;
|
|
} catch {
|
|
await setTimeout(50);
|
|
return waitTillWrittenToDisk(path);
|
|
}
|
|
}
|