File tree 1 file changed +31
-1
lines changed
1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,10 @@ $status = (new SingleCommandApplication)
125
125
).PHP_EOL ;
126
126
127
127
if ($ this ->dryRun ) {
128
- echo $ this ->differ ->diff ($ this ->composerJsonContents , $ outdatedComposerJsonContents );
128
+ $ this ->symfonyStyle ->writeln ($ this ->formatDiff ($ this ->differ ->diff (
129
+ $ this ->composerJsonContents ,
130
+ $ outdatedComposerJsonContents
131
+ )));
129
132
130
133
return $ this ;
131
134
}
@@ -291,6 +294,33 @@ $status = (new SingleCommandApplication)
291
294
292
295
return false ;
293
296
}
297
+
298
+ private function formatDiff (string $ diff ): string
299
+ {
300
+ $ lines = explode (
301
+ "\n" ,
302
+ $ diff ,
303
+ );
304
+
305
+ $ formatted = array_map (static function (string $ line ): string {
306
+ return preg_replace (
307
+ [
308
+ '/^(\+.*)$/ ' ,
309
+ '/^(-.*)$/ ' ,
310
+ ],
311
+ [
312
+ '<fg=green>$1</> ' ,
313
+ '<fg=red>$1</> ' ,
314
+ ],
315
+ $ line ,
316
+ );
317
+ }, $ lines );
318
+
319
+ return implode (
320
+ "\n" ,
321
+ $ formatted ,
322
+ );
323
+ }
294
324
})();
295
325
})
296
326
->run ();
You can’t perform that action at this time.
0 commit comments