MCPcopy
hub / github.com/formatjs/formatjs / parseTsconfigLine

Function parseTsconfigLine

tools/generate-package-tsconfigs.ts:52–78  ·  view source on GitHub ↗
(
  line: string
)

Source from the content-addressed store, hash-verified

50}
51
52function parseTsconfigLine(
53 line: string
54): {path: string; content: string} | null {
55 if (!line.startsWith('{')) {
56 return null
57 }
58
59 const parsed = JSON.parse(line) as RuleJson
60 if (parsed.type !== 'RULE' || parsed.rule?.ruleClass !== '_tsconfig_file') {
61 return null
62 }
63
64 const label = parsed.rule.name
65 if (!label) {
66 return null
67 }
68
69 const contentAttr = parsed.rule.attribute?.find(a => a.name === 'content')
70 if (!contentAttr?.stringValue) {
71 return null
72 }
73
74 return {
75 path: labelToPath(label),
76 content: JSON.stringify(JSON.parse(contentAttr.stringValue), null, 2),
77 }
78}
79
80async function main(): Promise<void> {
81 const args = minimist<Args>(process.argv.slice(2))

Callers 1

mainFunction · 0.85

Calls 2

labelToPathFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected