Skip to content

Commit 0bb63f0

Browse files
committed
update preview tokens write
1 parent eba0d42 commit 0bb63f0

1 file changed

Lines changed: 2 additions & 17 deletions

File tree

packages/cli/src/scripts/update-preview-tokens.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
import path from 'node:path';
21
import pc from 'picocolors';
32
import type { TransformedToken } from 'style-dictionary/types';
43
import config from './../../../../designsystemet.config.json' with { type: 'json' };
54
import { generate$Themes } from '../tokens/create/generators/$themes.js';
65
import { createTokens } from '../tokens/create.js';
76
import { buildOptions, processPlatform } from '../tokens/process/platform.js';
87
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';
109
import fs from '../utils/filesystem.js';
1110

1211
const OUTDIR = '../../internal/components/src/tokens/design-tokens';
1312

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-
2813
const toPreviewToken = (tokens: { token: TransformedToken; formatted: string }[]): PreviewToken[] =>
2914
tokens.map(({ token, formatted }) => {
3015
const [variable, value] = formatted.split(':');
@@ -95,7 +80,7 @@ export const formatTheme = async (themeConfig: Theme) => {
9580
console.log(`\n💾 Writing preview tokens`);
9681

9782
for (const [type, tokens] of Object.entries(tokensGroupedByType)) {
98-
write(
83+
fs.writeFiles(
9984
[
10085
{
10186
destination: `${type}.json`,

0 commit comments

Comments
 (0)