This commit is contained in:
Manav Rathi 2024-03-22 11:26:04 +05:30
parent 18deac3a41
commit 025ef4e1d9
No known key found for this signature in database

View file

@ -141,26 +141,18 @@ const writeNodeStream = async (
// - Export // - Export
export const exists = (path: string) => { const exists = (path: string) => fs.existsSync(path);
return fs.existsSync(path);
};
export const checkExistsAndCreateDir = async (dirPath: string) => { const checkExistsAndCreateDir = async (dirPath: string) => {
if (!fs.existsSync(dirPath)) { if (!fs.existsSync(dirPath)) {
await fs.mkdir(dirPath); await fs.mkdir(dirPath);
} }
}; };
export const saveStreamToDisk = async ( const saveStreamToDisk = writeStream;
filePath: string,
fileStream: ReadableStream<Uint8Array>,
) => {
await writeStream(filePath, fileStream);
};
export const saveFileToDisk = async (path: string, fileData: string) => { const saveFileToDisk = (path: string, contents: string) =>
await fs.writeFile(path, fileData); fs.writeFile(path, contents);
};
// - // -