Skip to content

Commit

Permalink
fixed new option clean for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Feb 11, 2025
1 parent 3c0bc9b commit 23e63da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

* 2.9.15
- fixed new option `clean` for `merge`

* 2.9.14
- added new option `clean`

Expand Down
2 changes: 1 addition & 1 deletion lib/merge-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ module.exports = async (reportDataList, userOptions = {}) => {
// init outputDir
const outputDir = path.dirname(outputFile);
// clean
Util.initDir(outputDir);
Util.initDir(outputDir, options.clean);
// for attachment path handler
options.outputDir = outputDir;

Expand Down
18 changes: 12 additions & 6 deletions lib/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ const Util = {
},

// empty or create dir
initDir: (dirPath) => {
if (fs.existsSync(dirPath)) {
Util.rmSync(dirPath);
initDir: (dirPath, clean) => {

if (clean) {
if (fs.existsSync(dirPath)) {
Util.rmSync(dirPath);
}
}

if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, {
recursive: true
});
}
fs.mkdirSync(dirPath, {
recursive: true
});
},

getEOL: function(content) {
Expand Down

0 comments on commit 23e63da

Please sign in to comment.