Output to file

This commit is contained in:
2022-02-16 00:17:19 +03:00
parent d47a4c634e
commit d5d5e5d59c
9 changed files with 82 additions and 15 deletions

23
Output.js Normal file
View File

@@ -0,0 +1,23 @@
const fs = require('fs')
module.exports = class Output {
constructor () {
this.content = ''
}
addLine (text) {
this.content += text + '\n'
}
submit () {
const filename = 'index.txt'
try {
fs.unlinkSync(filename)
} catch (error) {
console.error(error)
console.log('File probably doesnt exist')
}
fs.writeFileSync(filename, this.content)
}
}