@@ -70,8 +70,9 @@ export async function performUpdates<
70
70
const { files } = update
71
71
const formats = 'formats' in update ? { ...builtInFormatPlugins , ...update . formats } : builtInFormatPlugins
72
72
73
- const promises = pkgs . flatMap ( ( { dir, manifest, writeProjectManifest } ) =>
74
- Object . keys ( files ) . map ( async ( fileKey ) => {
73
+ const diffs = [ ]
74
+ for ( const { dir, manifest, writeProjectManifest } of pkgs ) {
75
+ for ( const [ fileKey , updateFile ] of Object . entries ( files ) ) {
75
76
const updateTargetFile = ! opts ?. test
76
77
const { file, formatPlugin } = parseFileKey ( fileKey , formats )
77
78
const resolvedPath = resolve ( dir , file )
@@ -83,12 +84,12 @@ export async function performUpdates<
83
84
_writeProjectManifest : writeProjectManifest ,
84
85
}
85
86
const actual = ( await fileExists ( resolvedPath ) ) ? await formatPlugin . read ( formatHandlerOptions ) : null
86
- const expected = await formatPlugin . update ( clone ( actual ) , files [ fileKey ] , formatHandlerOptions )
87
+ const expected = await formatPlugin . update ( clone ( actual ) , updateFile as any , formatHandlerOptions )
87
88
const equal =
88
89
( actual == null && expected == null ) ||
89
90
( actual != null && expected != null && ( await formatPlugin . equal ( expected , actual , formatHandlerOptions ) ) )
90
91
if ( equal ) {
91
- return
92
+ continue
92
93
}
93
94
94
95
if ( updateTargetFile ) {
@@ -97,23 +98,14 @@ export async function performUpdates<
97
98
} else {
98
99
await formatPlugin . write ( expected , formatHandlerOptions )
99
100
}
100
- return
101
+ continue
101
102
}
102
103
103
- return { actual, expected, path : resolvedPath }
104
- } )
105
- )
106
-
107
- const diffs = await Promise . allSettled ( promises )
108
- const errors = diffs . flatMap ( ( diff ) => {
109
- switch ( diff . status ) {
110
- case 'fulfilled' :
111
- return diff . value ?? [ ]
112
- case 'rejected' :
113
- return diff . reason
104
+ diffs . push ( { actual, expected, path : resolvedPath } )
114
105
}
115
- } )
116
- return errors . length > 0 ? errors : null
106
+ }
107
+
108
+ return diffs . length > 0 ? diffs : null
117
109
}
118
110
119
111
function printJsonDiff ( actual : unknown , expected : unknown , out : NodeJS . WriteStream ) {
0 commit comments