const fs = require("fs"); const path = require("path"); const prettier = require("prettier"); const projectRoot = path.resolve(__dirname, "..", ".."); const outputRoot = path.resolve(__dirname, "..", "output"); const files = [ { input: path.join(projectRoot, "assets", "index-CO3BwsT2.js"), output: path.join(outputRoot, "index-CO3BwsT2.pretty.js"), parser: "babel", }, { input: path.join(projectRoot, "assets", "index-DTPKq_WI.css"), output: path.join(outputRoot, "index-DTPKq_WI.pretty.css"), parser: "css", }, { input: path.join(projectRoot, "locales", "en-US.js"), output: path.join(outputRoot, "locales", "en-US.pretty.js"), parser: "babel", }, { input: path.join(projectRoot, "locales", "zh-CN.js"), output: path.join(outputRoot, "locales", "zh-CN.pretty.js"), parser: "babel", }, { input: path.join(projectRoot, "locales", "ru-RU.js"), output: path.join(outputRoot, "locales", "ru-RU.pretty.js"), parser: "babel", }, ]; async function main() { for (const file of files) { const source = fs.readFileSync(file.input, "utf8"); const formatted = await prettier.format(source, { parser: file.parser, printWidth: 100, trailingComma: "all", singleQuote: false, }); fs.mkdirSync(path.dirname(file.output), { recursive: true }); fs.writeFileSync(file.output, formatted, "utf8"); console.log(`formatted: ${path.relative(outputRoot, file.output)}`); } } main().catch((error) => { console.error(error); process.exitCode = 1; });