MCPcopy Create free account
hub / github.com/alibaba/open-code-review / readFileOrNull

Function readFileOrNull

scripts/github-actions/check-plugin-contract.js:549–560  ·  view source on GitHub ↗
(abs, { maxBytes = MAX_SCAN_BYTES } = {})

Source from the content-addressed store, hash-verified

547// no cap: silently treating an oversized-but-valid SKILL.md as "missing" would
548// point the reader at the wrong problem.
549function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) {
550 try {
551 const stat = fs.statSync(abs);
552 if (!stat.isFile() || stat.size > maxBytes) return null;
553 const buf = fs.readFileSync(abs);
554 // A NUL byte means binary; decoding it as text would produce noise.
555 if (buf.includes(0)) return null;
556 return buf.toString("utf8");
557 } catch (e) {
558 return null;
559 }
560}
561
562function readJsonOrNull(repoRoot, file) {
563 try {

Callers 3

runLinksCheckFunction · 0.85
runManifestsCheckFunction · 0.85

Calls

no outgoing calls

Tested by 1