'use strict';

var chunkAF3E2D32_cjs = require('./chunk-AF3E2D32.cjs');
var types = require('@storm-software/config-tools/types');
var writeFile$1 = require('@stryke/fs/write-file');
var prettier = require('prettier');

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

exports.writeFile = writeFile;
//# sourceMappingURL=chunk-UJJENY47.cjs.map
//# sourceMappingURL=chunk-UJJENY47.cjs.map