import * as fs from "fs" ; export class FileHandler { param filepath public stringFromFile ( filepath ) { if ( ! fs . existsSync ( filepath ) ) { console . error ( this , "File '" + filepath + "' does not exist, exiting." ) ; throw new Error ( `File '${ filepath }' not found.` ) ; } return fs . readFileSync ( filepath , { encoding : "utf8" } ) ; } param filepath param output public stringToFile ( filepath , output ) { if ( fs . existsSync ( filepath ) ) { console . log ( this , "FileHandler: file " + filepath + " already exists, overwriting it." ) ; } fs . writeFileSync ( filepath , output ) ; } }