1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-30 15:58:19 +09:00
cherrypick/packages/frontend/.storybook/preload-theme.ts

24 lines
624 B
TypeScript
Raw Normal View History

2023-03-19 22:22:14 +09:00
import { readFile, writeFile } from 'node:fs/promises';
import { resolve } from 'node:path';
import * as JSON5 from 'json5';
Promise.all([
readFile(resolve(__dirname, '../src/themes/_light.json5'), 'utf8'),
readFile(resolve(__dirname, '../src/themes/l-light.json5'), 'utf8'),
]).then((sources) => {
const base = JSON5.parse(sources[0]);
const theme = JSON5.parse(sources[1]);
writeFile(
resolve(__dirname, './theme.ts'),
`export default ${JSON.stringify(
Object.assign(theme, {
base: undefined,
props: Object.assign(base.props, theme.props),
}),
undefined,
2,
)} as const;`,
'utf8'
);
});