import * as fs from 'fs'; export class FileManager { static async readFile(path: string): Promise { return new Promise((resolve, reject) => { fs.readFile(path, 'utf8', (err, data) => { if (err || !data) { console.log("Couldn't read file:" + path); reject(err); return; } resolve(data); }); }); } static async writeFile(path: string, contents: string): Promise { return new Promise((resolve, reject) => { fs.writeFile(path, contents, 'utf8', (err) => { if (err) { console.log("Couldn't write file:" + path); reject(err); return; } resolve(); }); }); } static async copyFile(path1: string, path2: string): Promise { const fileContents = await FileManager.readFile(path1); await FileManager.writeFile(path2, fileContents); } static dirExists(path: string): boolean { return fs.existsSync(path) } }