UNPKG

smartech-base-expo-plugin

Version:

Smartech Base Expo SDK's React Native Plugin For React Native Projects.

39 lines (33 loc) 945 B
import { promises as fs } from 'fs'; export class FileManager { static async readFile(path: string): Promise<string> { try { return await fs.readFile(path, 'utf8'); } catch (err) { throw err; } } static async writeFile(path: string, contents: string): Promise<void> { try { await fs.writeFile(path, contents, 'utf8'); } catch (err) { throw err; } } static async copyFile(path1: string, path2: string): Promise<void> { try { const fileContents = await FileManager.readFile(path1); await FileManager.writeFile(path2, fileContents); } catch (err) { throw err; } } static async dirExists(path: string): Promise<boolean> { try { await fs.access(path); return true; } catch { return false; } } }