Skip to content

Commit 8694d62

Browse files
committed
Account for no workflow referred to
1 parent d0be040 commit 8694d62

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/cli/src/benchmark/scripts/list-suites.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@ import { writeFileSync } from 'node:fs';
44
import { collectSuites } from '../lib';
55
import type { Suites } from '../lib';
66

7-
function toSuitesList(suites: Suites) {
7+
async function exists(filePath: string) {
8+
const fullPath = path.resolve('src', 'benchmark', filePath);
9+
10+
try {
11+
await fs.access(fullPath);
12+
return true;
13+
} catch {
14+
return false;
15+
}
16+
}
17+
18+
async function toSuitesList(suites: Suites) {
819
let list = '';
920

1021
for (const [fullPath, suite] of Object.entries(suites)) {
@@ -16,7 +27,9 @@ function toSuitesList(suites: Suites) {
1627
const suiteName = suite.tasks[i].name.replace(suite.name, '').trim();
1728
const workflowPath = `./suites/workflows/${suiteId}-${i + 1}.json`;
1829

19-
list += `- [${suiteName}](${workflowPath})\n`;
30+
list += (await exists(workflowPath))
31+
? `- [${suiteName}](${workflowPath})\n`
32+
: `- ${suiteName}\n`;
2033
}
2134
}
2235

@@ -37,7 +50,7 @@ async function listSuites() {
3750
const after = oldDoc.slice(oldDoc.indexOf(MARK_END));
3851

3952
const suites = await collectSuites();
40-
const suitesList = toSuitesList(suites);
53+
const suitesList = await toSuitesList(suites);
4154

4255
const newDoc = [before, suitesList, after].join('\n');
4356

0 commit comments

Comments
 (0)