@@ -7,7 +7,7 @@ let project = process.argv.find((arg) => arg.includes('--project'));
7
7
if ( project ) {
8
8
project = project . slice ( '--project=' . length ) ;
9
9
}
10
- const ROOT_PATH = path . join ( __dirname , '..' , project ? `packages/ ${ project } ` : '.' ) ;
10
+ const ROOT_PATH = path . join ( __dirname , '..' , project ? `packages${ path . sep } ${ project } ` : '.' ) ;
11
11
const OUT_FILE = 'base64.out.ts' ;
12
12
13
13
const table = createStream ( {
@@ -24,9 +24,12 @@ const reduceDir = (dirPath: string, paths: string[] = []) => {
24
24
if ( statSync ( filePath ) . isDirectory ( ) ) {
25
25
reduceDir ( filePath , [ ...paths , file ] ) ;
26
26
} 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 ] ) ;
28
30
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 } ',
30
33
` ;
31
34
}
32
35
}
0 commit comments