Skip to content

Commit

Permalink
prettify typography generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs committed May 16, 2024
1 parent bcd6b93 commit 40720d7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions libs/@guardian/source-foundations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@emotion/react": "11.11.1",
"@guardian/design-tokens": "workspace:*",
"lightningcss": "1.24.0",
"prettier": "3.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"rollup": "4.17.2",
Expand Down
19 changes: 16 additions & 3 deletions libs/@guardian/source-foundations/scripts/build-type-presets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import fs from 'node:fs';
import { typography, typographyPresets } from '@guardian/design-tokens';
import prettierConfig from '@guardian/prettier';
import { format } from 'prettier';
import { fontArrayToString, pxStringToRem } from '../src/utils/convert-value';

const STRIP_WHITESPACE = /^\s+/gm;
Expand Down Expand Up @@ -61,6 +63,17 @@ const object = Object.entries(typographyPresets)
.join('')
.replace(STRIP_TABS, '');

fs.writeFileSync(cssOutputPath, banner + css);
fs.writeFileSync(objectOutputPath, banner + object);
console.log(`✓ ${presetTotal} presets built`);
void (async () => {
fs.writeFileSync(
cssOutputPath,
await format(banner + css, { filepath: cssOutputPath, ...prettierConfig }),
);
fs.writeFileSync(
objectOutputPath,
await format(banner + object, {
filepath: objectOutputPath,
...prettierConfig,
}),
);
console.log(`✓ ${presetTotal} presets built`);
})();
13 changes: 11 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 40720d7

Please sign in to comment.