@@ -135,9 +135,10 @@ export function stringifyContent (content: any, lang: string, options?: FormatOp
135
135
136
136
export function readSFC ( target : string , ig : Ignore ) : SFCFileInfo [ ] {
137
137
const targets = resolveGlob ( target )
138
- const cookedTargets = targets . filter ( t => {
138
+ const tmp = targets . filter ( t => {
139
139
return ! ig . ignores ( path . relative ( process . cwd ( ) , t ) )
140
- } ) . map ( p => path . resolve ( p ) )
140
+ } )
141
+ const cookedTargets = tmp . map ( p => path . resolve ( p ) )
141
142
debug ( 'readSFC: targets = ' , cookedTargets )
142
143
143
144
// TODO: async implementation
@@ -421,12 +422,24 @@ export function splitLocaleMessages (
421
422
return { sfc : messages , external : metaExternalLocaleMessages }
422
423
}
423
424
424
- export function readIgnoreFile ( ignorePath : string ) : string [ ] {
425
- const ignoreFiles = fs . readFileSync ( ignorePath , 'utf8' )
426
- . split ( / \r ? \n / g)
427
- . filter ( Boolean )
428
- console . log ( `ignoreFiles ${ ignoreFiles } ` )
429
- return ignoreFiles
425
+ export function readIgnoreFile ( target : string , ignoreFileName : string ) : string [ ] {
426
+ const ignoreFiles = glob . sync ( `${ target } /**/${ ignoreFileName } ` )
427
+ console . log ( `allignore ${ ignoreFiles } ` )
428
+ const ignoreTargets = [ ] as string [ ]
429
+ ignoreFiles . forEach ( ignoreFile => {
430
+ fs . readFileSync ( ignoreFile , 'utf8' )
431
+ . split ( / \r ? \n / g)
432
+ . filter ( Boolean )
433
+ . forEach ( ignoreTarget => {
434
+ ignoreTargets . push ( formatPath ( ignoreFile , ignoreTarget ) )
435
+ } )
436
+ } )
437
+ console . log ( `ignoreTargets ${ ignoreTargets } ` )
438
+ return ignoreTargets
439
+ }
440
+
441
+ function formatPath ( ignoreFile : string , ignoreTarget : string ) : string {
442
+ return path . join ( path . relative ( process . cwd ( ) , path . dirname ( ignoreFile ) ) , ignoreTarget )
430
443
}
431
444
432
445
export function returnIgnoreInstance ( ig : Ignore , ignoreFiles : string [ ] ) : void {
0 commit comments