|
1 | | -import path from 'node:path'; |
2 | 1 | import pc from 'picocolors'; |
3 | 2 | import type { TransformedToken } from 'style-dictionary/types'; |
4 | 3 | import config from './../../../../designsystemet.config.json' with { type: 'json' }; |
5 | 4 | import { generate$Themes } from '../tokens/create/generators/$themes.js'; |
6 | 5 | import { createTokens } from '../tokens/create.js'; |
7 | 6 | import { buildOptions, processPlatform } from '../tokens/process/platform.js'; |
8 | 7 | import { processThemeObject } from '../tokens/process/utils/getMultidimensionalThemes.js'; |
9 | | -import type { OutputFile, SizeModes, Theme } from '../tokens/types.js'; |
| 8 | +import type { SizeModes, Theme } from '../tokens/types.js'; |
10 | 9 | import fs from '../utils/filesystem.js'; |
11 | 10 |
|
12 | 11 | const OUTDIR = '../../internal/components/src/tokens/design-tokens'; |
13 | 12 |
|
14 | | -async function write(files: OutputFile[], outDir: string) { |
15 | | - for (const { destination, output } of files) { |
16 | | - if (destination) { |
17 | | - const filePath = path.join(outDir, destination); |
18 | | - const fileDir = path.dirname(filePath); |
19 | | - |
20 | | - console.log(`Writing file: ${pc.green(filePath)}`); |
21 | | - |
22 | | - await fs.mkdir(fileDir); |
23 | | - await fs.writeFile(filePath, output); |
24 | | - } |
25 | | - } |
26 | | -} |
27 | | - |
28 | 13 | const toPreviewToken = (tokens: { token: TransformedToken; formatted: string }[]): PreviewToken[] => |
29 | 14 | tokens.map(({ token, formatted }) => { |
30 | 15 | const [variable, value] = formatted.split(':'); |
@@ -95,7 +80,7 @@ export const formatTheme = async (themeConfig: Theme) => { |
95 | 80 | console.log(`\n💾 Writing preview tokens`); |
96 | 81 |
|
97 | 82 | for (const [type, tokens] of Object.entries(tokensGroupedByType)) { |
98 | | - write( |
| 83 | + fs.writeFiles( |
99 | 84 | [ |
100 | 85 | { |
101 | 86 | destination: `${type}.json`, |
|
0 commit comments