🌳
pt0/deployF/cliF/saveExampleMetaAI.mts
1import fs from 'fs'
3let capturedName: string | undefined, capturedClusterName: string | undefined
5export const captureSaveExampleMeta = (cfg: Record<string, unknown>) => {
6 if (!process.env.PTNODE_SAVE_EXAMPLE) return
7 if (cfg?.name && !capturedName) { capturedName = cfg.name as string; capturedClusterName = cfg.cluster_name as string | undefined }
8}
10if (process.env.PTNODE_SAVE_EXAMPLE && process.env.PTNODE_LOG_PATH) {
11 const logPath = process.env.PTNODE_LOG_PATH
12 process.on('exit', () => {
13 if (!capturedName) return
14 fs.writeFileSync(logPath + '.meta.json', JSON.stringify({name: capturedName, cluster_name: capturedClusterName}))
15 })