上下文:我正在使用一个小型nodejs工具(https://github.com/premkumaranand/csv-concat)来连接主要是键值对的csv文件,该工具允许用户添加在将连接的输出发送到结果文件之前,将文件路径作为键作为前缀。
前提:
问题:使用cli运行时连接效果很好,但使用
运行测试时则不能grunt test
测试用例为here。使用测试用例运行时,生成的文件只包含来自第一个'写入的内容。呼叫。见下文。
如何写入文件?
var outputStream = fs.createWriteStream(
options.dest,
{
flags: 'a'
});
//...
var records = csvFileParser.getRecords();
records.forEach(function (recordIter) {
outputStream.write(recordIter.join(options.delimiter) + '\n');
});
//...
outputStream.end();
...作为here。
到目前为止我尝试了什么?
而且:
outputStream.on("end", function() {
outputStream.end();
});
但没有运气。欢迎任何投入。