mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-19 08:02:16 +03:00
25 lines
437 B
JavaScript
25 lines
437 B
JavaScript
const fs = require('fs');
|
|
|
|
class File {
|
|
constructor(path) {
|
|
this.path = path;
|
|
this.content = '';
|
|
}
|
|
|
|
read() {
|
|
try {
|
|
const content = fs.readFileSync(this.path, { encoding: 'utf-8' });
|
|
this.content = content;
|
|
return this.content;
|
|
} catch (err) {
|
|
return err.message;
|
|
}
|
|
}
|
|
|
|
write(data) {
|
|
this.content = data;
|
|
fs.writeFileSync(this.path, this.content);
|
|
}
|
|
}
|
|
|
|
module.exports = File; |