Skip to content

Commit

Permalink
feat: Add css.fileName options. #48
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 7, 2020
1 parent f64fe17 commit 33936cc
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -27,7 +27,8 @@
"jest": {},
"svgtofont": {
"css": {
"fontSize": "12px"
"fontSize": "12px",
"fileName": "wcj"
}
},
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Expand Up @@ -201,7 +201,7 @@ export default async (options: SvgToFontOptions = {}) => {
fontSize: fontSize,
timestamp: new Date().getTime(),
prefix: options.classNamePrefix || options.fontName,
_opts: typeof options.css === 'boolean' ? {} : {...options.css}
_opts: typeof options.css === 'boolean' ? {} : { ...options.css }
});
}

Expand Down Expand Up @@ -239,7 +239,7 @@ export default async (options: SvgToFontOptions = {}) => {
fontname: options.fontName,
classNamePrefix: options.classNamePrefix,
_type: 'font-class',
_link: `${options.fontName}.css`,
_link: `${(options.css && typeof options.css !== 'boolean' && options.css.fileName) || options.fontName}.css`,
_IconHtml: cssIconHtml.join(''),
_title: options.website.title || options.fontName
};
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 7 additions & 1 deletion src/utils.ts
Expand Up @@ -214,6 +214,11 @@ export type CSSOptions = {
* https://github.com/jaywcjlove/svgtofont/issues/48#issuecomment-739547189
*/
cssPath?: string
/**
* Set file name
* https://github.com/jaywcjlove/svgtofont/issues/48#issuecomment-739547189
*/
fileName?: string
}

/**
Expand All @@ -223,8 +228,9 @@ export function copyTemplate(inDir: string, outDir: string, { _opts, ...vars }:
const removeFiles: Array<string> = [];
return new Promise((resolve, reject) => {
copy(inDir, outDir, {
...vars,
cssPath: _opts.cssPath || '',
...vars
filename: _opts.fileName || vars.fontname,
}, async (err, createdFiles) => {
if (err) reject(err);
createdFiles = createdFiles.map(filePath => {
Expand Down

0 comments on commit 33936cc

Please sign in to comment.