Skip to content

Commit

Permalink
fix: remove tmp file after processing
Browse files Browse the repository at this point in the history
  • Loading branch information
zaosoula committed Dec 29, 2022
1 parent 830610d commit ebdf1f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions bin/lcov-result-merger.js
Expand Up @@ -43,13 +43,16 @@ fg.stream(args.pattern, { absolute: true })
.pipe(lcovResultMerger(args))
.pipe(
through.obj((filePath) => {
const file = fs.openSync(filePath, 'r+');
const fileContentStr = fs.readFileSync(file, 'utf8');
const fileContentStr = fs.readFileSync(filePath, {
encoding: 'utf-8',
flag: 'r+'
});
fs.unlinkSync(filePath);

if (args.outFile) {
fs.writeFileSync(args.outFile, fileContentStr);
} else {
process.stdout.write(fileContentStr);
}
fs.closeSync(file);
})
);
13 changes: 8 additions & 5 deletions index.js
Expand Up @@ -368,20 +368,23 @@ module.exports = function (config) {
callback();
return;
}
const file = fs.openSync(filePath, 'r');
const fileContentStr = fs.readFileSync(file, 'utf8');
const fileContentStr = fs.readFileSync(filePath, {
encoding: 'utf8',
flag: 'r'
});
coverageFiles = processFile(
path.dirname(filePath),
fileContentStr,
coverageFiles,
config || {}
);
fs.closeSync(file);
callback();
},
function flush() {
const file = fs.openSync('lcov.info', 'w+');
fs.writeFileSync(file, Buffer.from(createRecords(coverageFiles)));
fs.writeFileSync('lcov.info', Buffer.from(createRecords(coverageFiles)), {
encoding: 'utf-8',
flag: 'w+'
});
this.push('lcov.info');
this.emit('end');
}
Expand Down

0 comments on commit ebdf1f0

Please sign in to comment.