Skip to content

Commit 06165c6

Browse files
authored
feat: support loading yaml config (#190)
1 parent c7b9152 commit 06165c6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"ttf2eot": "~3.1.0",
8686
"ttf2woff": "~3.0.0",
8787
"ttf2woff2": "~4.0.4",
88+
"yaml": "^2.1.3",
8889
"yargs": "~17.6.0"
8990
},
9091
"devDependencies": {

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import image2uri from 'image2uri';
66
import { SvgIcons2FontOptions } from 'svgicons2svgfont';
77
import color from 'colors-cli';
88
import { Config } from 'svgo';
9+
import * as YAML from 'yaml';
910
import { log } from './log';
1011
import { generateIconsSource, generateReactIcons } from './generate';
1112
import { createSVG, createTTF, createEOT, createWOFF, createWOFF2, createSvgSymbol, copyTemplate, CSSOptions, createHTML, createTypescript, TypescriptOptions } from './utils';
@@ -193,6 +194,13 @@ export default async (options: SvgToFontOptions = {}) => {
193194
if (fs.pathExistsSync(confPath)) {
194195
const conf = await fs.readJson(confPath);
195196
options = { ...options, ...conf };
197+
} else {
198+
// load yaml config
199+
const confPath = path.join(process.cwd(), '.svgtofontrc.yaml');
200+
if (fs.pathExistsSync(confPath)) {
201+
const conf = await YAML.parse(fs.readFileSync(confPath, 'utf-8'));
202+
options = { ...options, ...conf };
203+
}
196204
}
197205

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

0 commit comments

Comments
 (0)