mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-26 06:44:58 +00:00
12 lines
333 B
TypeScript
12 lines
333 B
TypeScript
import * as fs from 'fs/promises'
|
|
import * as path from 'path'
|
|
|
|
export async function writeFileSafely(targetPath: string, content: string, dryRun: boolean): Promise<void> {
|
|
if (dryRun) {
|
|
return
|
|
}
|
|
|
|
await fs.mkdir(path.dirname(targetPath), { recursive: true })
|
|
await fs.writeFile(targetPath, content, 'utf-8')
|
|
}
|