MCPcopy Create free account
hub / github.com/Y80/bmm / declareLocalType

Function declareLocalType

scripts/utils.mjs:139–158  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

137
138
139export async function declareLocalType() {
140 if (!process.env.DB_DRIVER) throw new Error('环境变量 DB_DRIVER 未定义')
141 const targetPath = path.resolve('local.d.ts')
142 const fileContent = `
143declare global {
144 type DB_DRIVER ='${process.env.DB_DRIVER}'
145}
146export {}
147`.trim()
148 try {
149 // 仅当内容变化时才写入
150 const existingContent = await asyncFs.readFile(targetPath, 'utf8').catch(() => '')
151 if (existingContent.trim() === fileContent) return
152 await asyncFs.writeFile(targetPath, fileContent, { encoding: 'utf-8' })
153 console.log(`Type declaration updated at ${targetPath}`)
154 } catch (error) {
155 console.error('Failed to generate type declaration:', error)
156 process.exit(1)
157 }
158}

Callers 7

vitest.config.tsFile · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
db-init.mjsFile · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected