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

Function readFileOrNull

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

Source from the content-addressed store, hash-verified

747// no cap: silently treating an oversized-but-valid SKILL.md as "missing" would
748// point the reader at the wrong problem.
749function readFileOrNull(abs, { maxBytes = MAX_SCAN_BYTES } = {}) {
750 try {
751 const stat = fs.statSync(abs);
752 if (!stat.isFile() || stat.size > maxBytes) return null;
753 const buf = fs.readFileSync(abs);
754 // A NUL byte means binary; decoding it as text would produce noise.
755 if (buf.includes(0)) return null;
756 return buf.toString("utf8");
757 } catch (e) {
758 return null;
759 }
760}
761
762function readJsonOrNull(repoRoot, file) {
763 try {

Callers 3

runLinksCheckFunction · 0.85
runManifestsCheckFunction · 0.85

Calls

no outgoing calls

Tested by 1