import { promises as fsp } from "fs" ; import * as path from "path" ; export async function writeFileSafe ( file , contents ) { await fsp . mkdir ( path . dirname ( file ) , { recursive : true } ) ; await fsp . writeFile ( file , contents ) ; return file ; } export async function writeFilesSafe ( files ) { return Promise . all ( files . map ( ( { file , contents } ) => writeFileSafe ( file , contents ) ) ) ; } export async function createTemporaryDirectory ( baseDir ) { return fsp . mkdtemp ( path . join ( baseDir , "remix-" ) ) ; }