MCPcopy
hub / github.com/benjamn/recast / tryToParseFile

Function tryToParseFile

test/typescript.ts:497–521  ·  view source on GitHub ↗
(source: any, absPath: any)

Source from the content-addressed store, hash-verified

495}
496
497function tryToParseFile(source: any, absPath: any) {
498 try {
499 return recast.parse(source, { parser });
500 } catch (e1: any) {
501 let options;
502 try {
503 options = JSON.parse(
504 fs
505 .readFileSync(path.join(path.dirname(absPath), "options.json"))
506 .toString(),
507 );
508 } catch (e2: any) {
509 if (e2.code !== "ENOENT") {
510 console.error(e2);
511 }
512 throw e1;
513 }
514
515 if (options.throws === e1.message) {
516 return null;
517 }
518
519 throw e1;
520 }
521}

Callers 1

testReprintingFunction · 0.85

Calls 2

joinMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…