@@ -38,26 +38,26 @@ function remarkSVGPaths(svgNode: Array<Node | string>): any{
3838 * @param args
3939 */
4040async function run ( args : IArgs ) {
41- const sourcePath = typeof args . path !== 'undefined' ? args . path : './' ;
41+ const basePath = typeof args . path !== 'undefined' ? args . path : './' ;
42+ const sourceDirPath = path . join ( basePath , '_sources' ) ;
4243 const idPrefix = typeof args . idPrefix !== 'undefined' ? args . idPrefix : 'icon' ;
4344
44- logger . info ( `svg merge symbols ${ sourcePath } ...` ) ;
45+ logger . info ( `svg merge symbols ${ basePath } ...` ) ;
4546
4647 const symbol : string [ ] = [ ] ;
4748 const iconCodes : string [ ] = [ ] ;
4849
49- const dirChildFiles = fs . readdirSync ( sourcePath ) ;
50+ const dirChildFiles = fs . readdirSync ( sourceDirPath ) ;
5051
51- const targetSvgFile = [ sourcePath , '..' , 'index.svg' ] . join ( '/ ') ;
52- const targetTypeFile = [ sourcePath , '..' , 'icon.d.ts' ] . join ( '/ ') ;
52+ const targetSvgFile = path . join ( basePath , 'index.svg' ) ;
53+ const targetTypeFile = path . join ( basePath , 'icon.d.ts' ) ;
5354
5455 dirChildFiles . forEach ( file => {
5556 if ( path . extname ( file ) == '.svg' ) {
5657 const filename = file . replace ( '.svg' , '' ) ;
5758 const iconCode = [ idPrefix , filename ] . join ( '-' ) ;
5859
59- const svgFile = fs . readFileSync ( [ sourcePath , file ] . join ( '/' ) ,
60- { encoding :'utf8' , flag :'r' } ) ;
60+ const svgFile = fs . readFileSync ( path . join ( basePath , file ) , { encoding :'utf8' , flag :'r' } ) ;
6161
6262 const svgContent = svgFile . toString ( ) ;
6363 const reg = new RegExp ( svgTagRule ) ;
@@ -67,7 +67,7 @@ async function run(args: IArgs) {
6767 const result = svgTag [ 0 ] ;
6868 const svgString = parse ( result ) ;
6969 const svgPaths = remarkSVGPaths ( svgString . children ) ;
70- symbol . push ( ` <symbol id="${ [ idPrefix , filename ] . join ( '-' ) } " viewBox="0 0 1024 1024">\n${ svgPaths . join ( '\n' ) } \n </symbol>` ) ;
70+ symbol . push ( ` <symbol id="${ iconCode } " viewBox="0 0 1024 1024">\n${ svgPaths . join ( '\n' ) } \n </symbol>` ) ;
7171 iconCodes . push ( `'${ filename } '` ) ;
7272
7373 logger . success ( `${ file } ` ) ;
@@ -89,7 +89,7 @@ ${symbol.join('\n\n')}\n
8989
9090
9191 // By OSX Notice
92- bash ( `osascript -e 'display notification "${ sourcePath } done" with title "publish done"'` ) ;
92+ bash ( `osascript -e 'display notification "${ basePath } done" with title "publish done"'` ) ;
9393}
9494
9595// run({path: './example/svg-symbols/_source'});
0 commit comments