Skip to content

Commit

Permalink
feat: support loading yaml config (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
serkodev authored Nov 28, 2022
1 parent c7b9152 commit 06165c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"ttf2eot": "~3.1.0",
"ttf2woff": "~3.0.0",
"ttf2woff2": "~4.0.4",
"yaml": "^2.1.3",
"yargs": "~17.6.0"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import image2uri from 'image2uri';
import { SvgIcons2FontOptions } from 'svgicons2svgfont';
import color from 'colors-cli';
import { Config } from 'svgo';
import * as YAML from 'yaml';
import { log } from './log';
import { generateIconsSource, generateReactIcons } from './generate';
import { createSVG, createTTF, createEOT, createWOFF, createWOFF2, createSvgSymbol, copyTemplate, CSSOptions, createHTML, createTypescript, TypescriptOptions } from './utils';
Expand Down Expand Up @@ -193,6 +194,13 @@ export default async (options: SvgToFontOptions = {}) => {
if (fs.pathExistsSync(confPath)) {
const conf = await fs.readJson(confPath);
options = { ...options, ...conf };
} else {
// load yaml config
const confPath = path.join(process.cwd(), '.svgtofontrc.yaml');
if (fs.pathExistsSync(confPath)) {
const conf = await YAML.parse(fs.readFileSync(confPath, 'utf-8'));
options = { ...options, ...conf };
}
}

const pkgPath = path.join(process.cwd(), 'package.json');
Expand Down

0 comments on commit 06165c6

Please sign in to comment.