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

Function readFileOrNull

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

Source from the content-addressed store, hash-verified

797// no cap: silently treating an oversized-but-valid SKILL.md as "missing" would
798// point the reader at the wrong problem.
799function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) {
800 try {
801 const stat = fs.statSync(abs);
802 if (!stat.isFile() || stat.size > maxBytes) return null;
803 const buf = fs.readFileSync(abs);
804 // A NUL byte means binary; decoding it as text would produce noise.
805 if (buf.includes(0)) return null;
806 return buf.toString("utf8");
807 } catch (e) {
808 return null;
809 }
810}
811
812function readJsonOrNull(repoRoot, file) {
813 try {

Callers 3

runLinksCheckFunction · 0.85
runManifestsCheckFunction · 0.85

Calls

no outgoing calls

Tested by 1