Minify _data/simple-icons.json on publish (#11903)

This commit is contained in:
LitoMore 2024-10-01 11:52:48 +08:00 committed by GitHub
parent 14ccea31a8
commit 3fa891560b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -46,6 +46,8 @@ jobs:
run: node scripts/release/reformat-markdown.js "${{ steps.get-version.outputs.version }}"
- name: Update SDK Typescript definitions
run: node scripts/release/update-sdk-ts-defs.js
- name: Minify icons data file
run: node scripts/release/minify-icons-data.js
- name: Build NodeJS package
run: npm run build
- name: Deploy to NPM

View File

@ -0,0 +1,9 @@
/**
* @file
* Minify _data/simple-icons.json file.
*/
import {getIconsData} from '../../sdk.mjs';
import {writeIconsData} from '../utils.js';
const icons = await getIconsData();
await writeIconsData({icons}, undefined, true);

View File

@ -32,14 +32,16 @@ export const getJsonSchemaData = async (
* Write icons data to _data/simple-icons.json.
* @param {{icons: IconData[]}} iconsData Icons data object.
* @param {string} rootDirectory Path to the root directory of the project.
* @param {boolean} minify Whether to minify the JSON output.
*/
export const writeIconsData = async (
iconsData,
rootDirectory = path.resolve(__dirname, '..'),
minify,
) => {
await fs.writeFile(
getIconDataPath(rootDirectory),
`${JSON.stringify(iconsData, null, 4)}\n`,
`${JSON.stringify(iconsData, null, minify ? 0 : 4)}\n`,
'utf8',
);
};