26 lines
416 B
JavaScript
26 lines
416 B
JavaScript
const fs = require('fs')
|
|
|
|
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)
|
|
}
|
|
}
|
|
|
|
module.exports = new Output()
|