const fs = require('fs');
const consola = require('consola');

class Fs {
    writeFile(filepath, string, callback) {
        const write = fs.writeFile(filepath, string, (err, written, string) => {
            if (err) {
                consola.error(`写入失败`, err);
                callback(false);
            } else {
                consola.success(`写入成功`);
                callback(true);
            }
        });
    }

    readFile(filepath) {
        const data = fs.readFileSync(filepath);
        return data.toString();
    }
}

module.exports = Fs;
