From 1aa7a026e953cc80e2b9da5d4207e4113983ae4a Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Mon, 2 Dec 2024 14:15:32 +0300 Subject: [PATCH] Update build-tokens.js --- packages/themes/scripts/build-tokens.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/themes/scripts/build-tokens.js b/packages/themes/scripts/build-tokens.js index dd4455555..f4e1650cf 100644 --- a/packages/themes/scripts/build-tokens.js +++ b/packages/themes/scripts/build-tokens.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const prettier = require('prettier'); // prettier-ignore const THEME_COMPONENTS = [ @@ -101,7 +102,7 @@ try { console.error(err); } -THEME_COMPONENTS.forEach((comp) => { +THEME_COMPONENTS.forEach(async (comp) => { const data = fs.readFileSync(path.resolve(rootDir, `src/presets/${themeName}/${comp.toLowerCase()}/index.js`), { encoding: 'utf8', flag: 'r' }); let theme = data.replace('export default', 'module.exports = '); @@ -237,7 +238,10 @@ ${defaultText} } `; - fs.writeFileSync(outputFile, text, 'utf8'); + const prettierConfig = await prettier.resolveConfig(__dirname); + const formattedText = prettier.format(text, { ...prettierConfig, parser: 'typescript' }); + + fs.writeFileSync(outputFile, formattedText, 'utf8'); } catch (err) { console.error(err); }