@@ -31,29 +31,28 @@ const mergeFiles = mergeWithCustomizers((value, srcValue, key, target, source, s
3131 }
3232} , customizers . overwriteArrays )
3333
34- const fileEntries = ( dir , files , options , { allowMultipleSources = true } = { } ) => {
34+ const fileEntries = ( dir , files , options ) => {
3535 const results = [ ]
3636
37- for ( const [ key , source ] of Object . entries ( files ) ) {
37+ for ( const [ key , value ] of Object . entries ( files ) ) {
3838 // remove any false values first since that means those targets are skipped
39- if ( source === false ) {
39+ if ( value === false ) {
4040 continue
4141 }
4242
4343 // target paths need to be joined with dir and templated
4444 const target = join ( dir , template ( key , options ) )
4545
46- if ( Array . isArray ( source ) ) {
47- // When turning an object of files into all its entries, we allow
48- // multiples when applying changes, but not when checking for changes
49- // since earlier files would always return as needing an update. So we
50- // either allow multiples and return the array or only return the last
51- // source file in the array.
52- const sources = allowMultipleSources ? source : source . slice ( - 1 )
53- results . push ( ...sources . map ( s => [ target , s ] ) )
54- } else {
55- results . push ( [ target , source ] )
56- }
46+ // Allow an array of values to merge into a single source to be
47+ // applied or diffed against the target. This is how overwrite:false
48+ // works and they are merged.
49+ const source = Array . isArray ( value )
50+ ? value . reduce ( ( acc , { file, ...rest } ) => {
51+ acc . file . push ( file )
52+ return Object . assign ( acc , rest )
53+ } , { file : [ ] } ) : value
54+
55+ results . push ( [ target , source ] )
5756 }
5857
5958 return results
0 commit comments