diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb849f..e11c544 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +* 2.9.9 + - fixed trend file issue (#160) + * 2.9.8 - fixed wrong duration for shards (#157) diff --git a/lib/index.js b/lib/index.js index 762270c..508977e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,4 @@ +const fs = require('fs'); const path = require('path'); const EC = require('eight-colors'); const { getSystemInfo, getTickInfo } = require('./utils/system.js'); @@ -95,8 +96,30 @@ class MonocartReporter { } cleanOutputDir() { - Util.initDir(this.options.outputDir); - // console.log('=========================== ', 'cleanOutputDir'); + + // after trends + const outputDir = this.options.outputDir; + if (!fs.existsSync(outputDir)) { + return; + } + + const list = fs.readdirSync(outputDir); + if (!list.length) { + return; + } + + Util.logInfo('clean output dir ...'); + for (const item of list) { + + // console.log('remove', item); + try { + Util.rmSync(path.resolve(outputDir, item)); + } catch (e) { + // console.log('=======================', e); + } + + } + } // ========================================================================== diff --git a/package.json b/package.json index 66e82a6..2ce26f7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "koa": "^2.15.3", "koa-static-resolver": "^1.0.6", "lz-utils": "^2.1.0", - "monocart-coverage-reports": "^2.11.1", + "monocart-coverage-reports": "^2.11.2", "monocart-locator": "^1.0.2", "nodemailer": "^6.9.16" }, diff --git a/tests/playwright.config.js b/tests/playwright.config.js index c40a2f3..f66fd8c 100644 --- a/tests/playwright.config.js +++ b/tests/playwright.config.js @@ -186,6 +186,18 @@ module.exports = { trend: () => { return new Promise((resolve) => { + + // const fs = require('node:fs'); + // fs.readFile('./.temp/monocart/index.json', (error, data) => { + // if (error) { + // console.log(error); + // resolve(); + // return; + // } + // const json = JSON.parse(data); + // resolve(json); + // }); + const axios = require('axios'); axios.get('https://cenfun.github.io/monocart-reporter/index.json').then((res) => { const json = res.data;