2024-08-22 18:12:01 +08:00
|
|
|
import fs from 'node:fs';
|
|
|
|
import path from 'node:path';
|
|
|
|
|
2024-08-22 20:56:34 +08:00
|
|
|
export function getLastModifiedReportHTMLFile(dirPath: string) {
|
2024-08-22 18:12:01 +08:00
|
|
|
let latestFile = null;
|
|
|
|
let latestMtime = 0;
|
|
|
|
|
|
|
|
function traverse(currentPath: string) {
|
|
|
|
const files = fs.readdirSync(currentPath);
|
|
|
|
|
2025-03-12 13:49:50 +08:00
|
|
|
files
|
|
|
|
.filter((file) => /merged/.test(file))
|
|
|
|
.forEach((file) => {
|
|
|
|
const filePath = path.join(currentPath, file);
|
|
|
|
const stats = fs.statSync(filePath);
|
2024-08-22 18:12:01 +08:00
|
|
|
|
2025-03-12 13:49:50 +08:00
|
|
|
if (stats.isDirectory()) {
|
|
|
|
traverse(filePath);
|
|
|
|
} else if (
|
|
|
|
stats.isFile() &&
|
|
|
|
path.extname(file).toLowerCase() === '.html' &&
|
|
|
|
!file.toLowerCase().startsWith('latest')
|
2024-08-22 20:56:34 +08:00
|
|
|
) {
|
2025-03-12 13:49:50 +08:00
|
|
|
// Read the file content
|
|
|
|
const content = fs.readFileSync(filePath, 'utf8');
|
|
|
|
if (
|
|
|
|
stats.mtimeMs > latestMtime &&
|
|
|
|
/groupDescription":".*\/playwright\/ai-auto-todo/i.test(content)
|
|
|
|
) {
|
|
|
|
// Check if the content includes 'todo report'
|
|
|
|
latestMtime = stats.mtimeMs;
|
|
|
|
latestFile = filePath;
|
|
|
|
// console.log('filePath', filePath);
|
|
|
|
} else {
|
|
|
|
console.log('file not matching', filePath);
|
|
|
|
}
|
2024-08-22 18:12:01 +08:00
|
|
|
}
|
2025-03-12 13:49:50 +08:00
|
|
|
});
|
2024-08-22 18:12:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
traverse(dirPath);
|
|
|
|
return latestFile;
|
|
|
|
}
|