@@ -7,7 +7,7 @@ let project = process.argv.find((arg) => arg.includes('--project'));
77if ( project ) {
88 project = project . slice ( '--project=' . length ) ;
99}
10- const ROOT_PATH = path . join ( __dirname , '..' , project ? `packages/ ${ project } ` : '.' ) ;
10+ const ROOT_PATH = path . join ( __dirname , '..' , project ? `packages${ path . sep } ${ project } ` : '.' ) ;
1111const OUT_FILE = 'base64.out.ts' ;
1212
1313const table = createStream ( {
@@ -24,9 +24,12 @@ const reduceDir = (dirPath: string, paths: string[] = []) => {
2424 if ( statSync ( filePath ) . isDirectory ( ) ) {
2525 reduceDir ( filePath , [ ...paths , file ] ) ;
2626 } else if ( / ^ b a s e 6 4 \. [ \s \S ] + \. [ \s \S ] + $ / . test ( file ) && file !== OUT_FILE ) {
27- table . write ( [ ( filePath . match ( / (?< = p a c k a g e s \/ ) [ \s \S ] + ?(? = \/ ) / ) as string [ ] ) ?. [ 0 ] , file ] ) ;
27+ const filePathReg = new RegExp ( `(?<=packages\\${ path . sep } )[\\s\\S]+?(?=\\${ path . sep } )` ) ;
28+ const targetPath = filePath . match ( filePathReg ) as string [ ] ;
29+ table . write ( [ targetPath ?. [ 0 ] , file ] ) ;
2830 const bitmap = readFileSync ( filePath , { encoding : 'base64' } ) ;
29- output += String . raw ` '${ file . match ( / (?< = \. ) [ \s \S ] + (? = \. ) / ) ! [ 0 ] } ': '${ bitmap } ',
31+ const fileMiddleName = file . match ( / (?< = \. ) [ \s \S ] + (? = \. ) / ) as string [ ] ;
32+ output += String . raw ` '${ fileMiddleName ?. [ 0 ] } ': '${ bitmap } ',
3033` ;
3134 }
3235 }
0 commit comments