Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Resolved conflicts by taking GitHub versions for: - .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml Kept deploy.sh updated to: - Pull from GitHub (primary source) - Push to Gitea (push-mirror) - Build from site/ directory (GitHub structure) Co-Authored-By: Paperclip <noreply@paperclip.ing>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import type { CacheFs } from '../shared/lib/utils';
|
|
/**
|
|
* MultiFileWriter is a utility for writing multiple files in parallel that
|
|
* guarantees that all files will be written after their containing directory
|
|
* is created, and that the directory will only be created once.
|
|
*/
|
|
export declare class MultiFileWriter {
|
|
/**
|
|
* The file system methods to use.
|
|
*/
|
|
private readonly fs;
|
|
/**
|
|
* The tasks to be written.
|
|
*/
|
|
private readonly tasks;
|
|
constructor(
|
|
/**
|
|
* The file system methods to use.
|
|
*/
|
|
fs: Pick<CacheFs, 'mkdir' | 'writeFile'>);
|
|
/**
|
|
* Finds or creates a task for a directory.
|
|
*
|
|
* @param directory - The directory to find or create a task for.
|
|
* @returns The task for the directory.
|
|
*/
|
|
private findOrCreateTask;
|
|
/**
|
|
* Appends a file to the writer to be written after its containing directory
|
|
* is created. The file writer should be awaited after all the files have been
|
|
* appended. Any async operation that occurs between appending and awaiting
|
|
* may cause an unhandled promise rejection warning and potentially crash the
|
|
* process.
|
|
*
|
|
* @param filePath - The path to the file to write.
|
|
* @param data - The data to write to the file.
|
|
*/
|
|
append(filePath: string, data: Buffer | string): void;
|
|
/**
|
|
* Returns a promise that resolves when all the files have been written.
|
|
*/
|
|
wait(): Promise<unknown>;
|
|
}
|