I'm writing an extension for vscode and it is the first time I use JS (node.js, don't know if there is a difference) and it all works great except for the fs.append()
function.
It seems to mix up inputs, so if input is:
Foo
Bar
It sometimes outputs:
Bar
Foo
but it doesn't happen all the time and i can't quite figure out why.
Here is my code (at least the important parts)
const fs = require('fs');
var path = 'includes/hello/hello.cpp';
var file = '.vscode/tasks.json';
var lineReader = require('readline').createInterface({
input: fs.createReadStream(file)});
lineReader.on('line', function(line) {
fs.appendFile(file, line + '\n', function(err) {
if(err) {
return console.error(err);
}
});
});