import { ensureDir , writeFile } from 'fs-extra' ; import { dirname } from 'path' ; import prettier from 'prettier' ; import type { Observable } from 'rxjs' ; import { defer } from 'rxjs' ; param filepath param content returns export default function saveTextFile ( filepath , content ) { return defer ( async ( ) => { await ensureDir ( dirname ( filepath ) ) ; const formattedContent = prettier . format ( content , { filepath } ) ; await writeFile ( filepath , formattedContent , 'utf-8' ) ; return filepath ; } ) ; }