diff --git a/lib/index.d.ts b/lib/index.d.ts index 175c382..1e0dafd 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -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; + addFromDir: (dir: string, remove?: boolean) => Promise; /** generate report */ generate: () => Promise; diff --git a/lib/index.js b/lib/index.js index fcca403..0344fae 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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);