Skip to content

Commit

Permalink
whether to remove dir after added
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Sep 25, 2024
1 parent 8235d9c commit 730de44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,9 @@ declare namespace MCR {
/**
* add V8 coverage from a dir
* @param dir node v8 coverage dir
* @param remove whether to remove dir after added
*/
addFromDir: (dir: string) => Promise<void>;
addFromDir: (dir: string, remove?: boolean) => Promise<void>;

/** generate report */
generate: () => Promise<CoverageResults | undefined>;
Expand Down
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ class CoverageReport {
}

// add coverage from dir
async addFromDir(dir) {
async addFromDir(dir, remove) {
const time_start = Date.now();
const results = await readFromDir(this, dir);
// remove dir after added
if (!Util.isDebug()) {
if (typeof remove !== 'boolean') {
remove = !Util.isDebug();
}
if (remove) {
Util.rmSync(dir);
}
Util.logTime(`added from dir: ${dir}`, time_start);
Expand Down

0 comments on commit 730de44

Please sign in to comment.