Skip to content

Commit

Permalink
feat: Supports .svgtofontc Configuration File.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Feb 10, 2022
1 parent e2ab7e8 commit d13633f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,27 @@ npm i svgtofont
"scripts": {
"font": "svgtofont --sources ./svg --output ./font --fontName uiw-font"
},
"svgtofont": {
"css": {
"fontSize": "12px"
}
}
}
```

You can add configuration to package.json. [#48](https://github.com/jaywcjlove/svgtofont/issues/48)

Supports `.svgtofontc` Configuration File.

```js
{
"src": "./icon",
"dist": "./fonts",
"fontName": "svgtofont",
"css": true
}
```

#### Using With Nodejs

```js
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ export default async (options: SvgToFontOptions = {}) => {
}
}

const confPath = path.join(process.cwd(), '.svgtofontrc');
if (fs.pathExistsSync(confPath)) {
const pkg = require(confPath);
if (pkg.svgtofont) {
options = { ...options, ...pkg.svgtofont }
}
}

options.dist = options.dist || path.join(process.cwd(), 'fonts');
options.src = options.src || path.join(process.cwd(), 'svg');
options.startUnicode = options.startUnicode || 0xea01;
Expand Down

0 comments on commit d13633f

Please sign in to comment.