Skip to content

Commit 5855673

Browse files
authored
Performance optimization and bug fix for asset files (#355)
Signed-off-by: Gavin John <[email protected]>
1 parent db7e6dc commit 5855673

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/rules/assets.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@ import processFiles from "../process.js";
44
export default async function (octokit: Octokit, config: Config, files: File[]) : Promise<Rule[]> {
55
// Get results
66
let res : Rule[][] = await Promise.all(files.map(async file => {
7+
let filename = '';
78
if (file.filename.startsWith("assets/eip-") && !files.some(f => f.filename == `EIPS/${file.filename.split("/")[2]}.md`)) {
8-
return processFiles(octokit, config, [{
9-
filename: `EIPS/${file.filename.split("/")[1]}.md`,
10-
status: 'modified',
11-
}]);
9+
filename = `EIPS/${file.filename.split("/")[1]}.md`;
1210
} else if (file.filename.startsWith("assets/erc-") && !files.some(f => f.filename == `ERCS/${file.filename.split("/")[2]}.md`)) {
13-
return processFiles(octokit, config, [{
14-
filename: `ERCS/${file.filename.split("/")[1]}.md`,
15-
status: 'modified',
16-
}]);
11+
filename = `ERCS/${file.filename.split("/")[1]}.md`;
1712
}
18-
return [];
13+
if (filename == '') {
14+
return []; // Not an asset file
15+
}
16+
if (files.some(file => file.filename == filename)) {
17+
return []; // Already covered by the relevant rules, so avoid potential conflicts by short circuiting
18+
}
19+
return processFiles(octokit, config, [{
20+
filename,
21+
status: 'modified',
22+
}]);
1923
}));
2024

2125
// Merge results

0 commit comments

Comments
 (0)