Skip to content

Commit

Permalink
Merge pull request #352 from db-ui/feat-skip-clean
Browse files Browse the repository at this point in the history
feat: add skip clean arg
  • Loading branch information
nmerget authored Nov 29, 2024
2 parents b3c6948 + c6abe87 commit 66a0606
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"build:01_icon_fonts_common": "esbuild src/generate-icon-fonts/cli.ts --bundle --outfile=dist/index.mjs --platform=node --packages=external --format=esm",
"build:02_icon_fonts_styles": "cpr src/generate-icon-fonts/styles dist/styles -o",
"build:03_icon_fonts_templates": "cpr src/generate-icon-fonts/templates dist/templates -o",
"build:04_rest": "tsc",
"lint": "eslint src --ext ts",
"prepare": "husky",
"test": "vitest run --no-file-parallelism"
Expand Down
3 changes: 1 addition & 2 deletions src/clean-icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { globSync } from "glob";
import { GlobOptionsWithFileTypesFalse, globSync } from "glob";

import SVGFixer from "oslllo-svg-fixer";
import { GlobOptionsWithFileTypesFalse } from "glob/dist/commonjs/glob";
import { error } from "console";

const cleanIcons = async (
Expand Down
6 changes: 6 additions & 0 deletions src/generate-icon-fonts/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export const gifOptions: ProgrammOptionsType[] = [
array: true,
defaultValue: [],
},
{
name: "skipClean",
description: "Skip cleaning process",
defaultValue: false,
short: "sc",
},
{
name: "withSizes",
description: "Splits the font into different sizes",
Expand Down
19 changes: 12 additions & 7 deletions src/generate-icon-fonts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const generateIconFonts = async (values: OptionsType): Promise<unknown> => {
debug = false,
overwriteSources = false,
traceResolution = "600",
skipClean = false,
} = values;
const dist = `${src}/fonts`;
const temporaryDirectory = `${src}/tmp`;
Expand All @@ -44,13 +45,17 @@ const generateIconFonts = async (values: OptionsType): Promise<unknown> => {
debugLog(debug, "---Start gathering icon---");
const iconPaths = gatherIcons(temporaryDirectory, values);

debugLog(debug, "---Start cleaning icon---");
await cleanIcons(
`${temporaryDirectory}/*`,
ignoreVariants,
traceResolution,
debug,
);
if (skipClean) {
debugLog(debug, "---Skip cleaning icon---");
} else {
debugLog(debug, "---Start cleaning icon---");
await cleanIcons(
`${temporaryDirectory}/*`,
ignoreVariants,
traceResolution,
debug,
);
}

debugLog(debug, "---Start svg to font ---");
const allTemporaryDirectories = FSE.readdirSync(temporaryDirectory);
Expand Down
5 changes: 3 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Config } from "svgo";
import { SvgIcons2FontOptions } from "svgicons2svgfont";
import { SVGIcons2SVGFontStreamOptions } from "svgicons2svgfont";

export type ProgrammOptionsType = {
name: string;
Expand All @@ -16,6 +16,7 @@ export type OptionsType = {
src: string;
cleanIgnoreVariants: string[];
variants: string[];
skipClean?: boolean;
debug?: boolean;
dryRun?: boolean;
overwriteSources?: boolean;
Expand All @@ -35,5 +36,5 @@ export type OptionsType = {
/**
* This is the setting for [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont/tree/dd713bea4f97afa59f7dba6a21ff7f22db565bcf#api)
*/
svgicons2svgfont?: SvgIcons2FontOptions;
svgicons2svgfont?: SVGIcons2SVGFontStreamOptions;
};
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"compilerOptions": {
"target": "esnext",
"module": "NodeNext",
"module": "ESNext",
"declaration": true,
"outDir": "dist",
"moduleResolution": "NodeNext",
"moduleResolution": "Bundler",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,

"skipLibCheck": true,
"strict": true /* Enable all strict type-checking options. */,

/* Additional Checks */
Expand Down

0 comments on commit 66a0606

Please sign in to comment.