UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

28 lines (24 loc) 854 B
'use strict'; var chunkGRNJVY7I_cjs = require('./chunk-GRNJVY7I.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 : ""}`); } } chunkGRNJVY7I_cjs.__name(writeFile, "writeFile"); exports.writeFile = writeFile;