@@ -142,9 +142,10 @@ export function stringifyContent (content: any, lang: string, options?: FormatOp
142142
143143export function readSFC ( target : string , ig : Ignore ) : SFCFileInfo [ ] {
144144 const targets = resolveGlob ( target )
145- const cookedTargets = targets . filter ( t => {
145+ const tmp = targets . filter ( t => {
146146 return ! ig . ignores ( path . relative ( process . cwd ( ) , t ) )
147- } ) . map ( p => path . resolve ( p ) )
147+ } )
148+ const cookedTargets = tmp . map ( p => path . resolve ( p ) )
148149 debug ( 'readSFC: targets = ' , cookedTargets )
149150
150151 // TODO: async implementation
@@ -428,12 +429,24 @@ export function splitLocaleMessages (
428429 return { sfc : messages , external : metaExternalLocaleMessages }
429430}
430431
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 )
437450}
438451
439452export function returnIgnoreInstance ( ig : Ignore , ignoreFiles : string [ ] ) : void {
0 commit comments