MCPcopy
hub / github.com/tldraw/tldraw / writeCodeFile

Function writeCodeFile

internal/scripts/lib/file.ts:39–56  ·  view source on GitHub ↗
(
	generator: string | null,
	language: 'typescript' | 'javascript',
	filePath: string,
	code: string
)

Source from the content-addressed store, hash-verified

37
38const oxfmtConfig = json5.parse(readFileSync(join(REPO_ROOT, '.oxfmtrc.json'), 'utf8'))
39export async function writeCodeFile(
40 generator: string | null,
41 language: 'typescript' | 'javascript',
42 filePath: string,
43 code: string
44) {
45 const source = generator
46 ? `
47 // This file is automatically generated by ${generator}.
48 // Do not edit manually. Or do, I'm a comment, not a cop.
49
50 ${code}
51 `
52 : code
53 const ext = language === 'typescript' ? 'ts' : 'js'
54 const result = await format(`file.${ext}`, source, oxfmtConfig)
55 await writeStringFile(filePath, result.code)
56}
57
58export async function writeStringFile(filePath: string, contents: string) {
59 await writeFile(filePath, Buffer.from(contents, 'utf-8'))

Callers 11

copyIconsFunction · 0.90
copyTranslationsFunction · 0.90
copyWatermarksFunction · 0.90
createVersionFilesFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
checkLibraryContentsFunction · 0.90

Calls 2

writeStringFileFunction · 0.85
formatFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…