WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 30cc6f9

Browse files
committed
feat: readFileSync error check
1 parent 96da1c9 commit 30cc6f9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/check-i18n.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@ const isAllowedString = (text) => {
8080
const toPosixPath = (filePath) => filePath.split(path.sep).join(POSIX_SEP);
8181

8282
const collectViolations = (filePath) => {
83-
const content = fs.readFileSync(filePath, 'utf-8');
83+
let content;
84+
try {
85+
content = fs.readFileSync(filePath, 'utf-8');
86+
} catch (error) {
87+
console.warn(`Warning: Could not read ${filePath}: ${error.message}`);
88+
return [];
89+
}
90+
8491
const lines = stripComments(content).split('\n');
8592
const violations = [];
8693

0 commit comments

Comments
 (0)