Skip to content

Commit

Permalink
fix: overwrite flag (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr authored Mar 7, 2022
1 parent 6577f82 commit 1944c4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
16 changes: 12 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ const { log, debugLog } = require('./logger');
const generateReport = require('./generateReport');

async function beforeRunHook({ config }) {
const { outputDir } = await setConfig(config);
const { outputDir, jsonDir, reporterOptions } = await setConfig(config);

log(`Remove output folder ${outputDir}`);
// Only if overwrite is set to false delete only .jsons folder and keep the html files
// By default overwrite is set to undefined (which means true by mochawesome-report-generator)
if (reporterOptions.overwrite === false) {
log(`Remove .jsons folder ${jsonDir}`);

await fse.remove(outputDir);
await fse.remove(jsonDir);
} else {
log(`Remove output folder ${outputDir}`);

await fse.remove(outputDir);
}
}

async function afterRunHook() {
await generateReport();

debugLog('done')
debugLog('done');
}

module.exports = {
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cypress-mochawesome-reporter",
"version": "2.4.0-rc.0",
"version": "2.4.0",
"description": "Zero config Mochawesome reporter for Cypress with screenshots",
"engines": {
"node": ">=10"
Expand Down

0 comments on commit 1944c4a

Please sign in to comment.