Skip to content

Commit

Permalink
fixed trend file issue (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Nov 7, 2024
1 parent 3c5f1dc commit ee6a215
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 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.9
- fixed trend file issue (#160)

* 2.9.8
- fixed wrong duration for shards (#157)

Expand Down
27 changes: 25 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs');
const path = require('path');
const EC = require('eight-colors');
const { getSystemInfo, getTickInfo } = require('./utils/system.js');
Expand Down Expand Up @@ -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);
}

}

}

// ==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
12 changes: 12 additions & 0 deletions tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ee6a215

Please sign in to comment.