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