import { __name } from './chunk-6AXVLTU5.js';
import { LogLevelLabel } from '@storm-software/config-tools/types';
import { writeFile as writeFile$1 } from '@stryke/fs/write-file';
import { resolveConfig, format } from 'prettier';

async function writeFile(log, filepath, content, skipFormat = false) {
  try {
    if (skipFormat) {
      await writeFile$1(filepath, content);
    } else {
      const config = await resolveConfig(filepath);
      const formatted = await format(content, {
        ...config ?? {},
        filepath
      });
      await writeFile$1(filepath, formatted || "");
    }
  } catch (error) {
    log(LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk 
${error?.message ? error.message : ""}`);
  }
}
__name(writeFile, "writeFile");

export { writeFile };
//# sourceMappingURL=chunk-V3VWCAQH.js.map
//# sourceMappingURL=chunk-V3VWCAQH.js.map