MCPcopy Index your code
hub / github.com/react/react / printDiff

Function printDiff

scripts/release/utils.js:161–186  ·  view source on GitHub ↗
(path, beforeContents, afterContents)

Source from the content-addressed store, hash-verified

159 logger(promise, text, {estimate});
160
161const printDiff = (path, beforeContents, afterContents) => {
162 const patch = createPatch(path, beforeContents, afterContents);
163 const coloredLines = patch
164 .split('\n')
165 .slice(2) // Trim index file
166 .map((line, index) => {
167 if (index <= 1) {
168 return theme.diffHeader(line);
169 }
170 switch (line[0]) {
171 case '+':
172 return theme.diffAdded(line);
173 case '-':
174 return theme.diffRemoved(line);
175 case ' ':
176 return line;
177 case '@':
178 return null;
179 case '\\':
180 return null;
181 }
182 })
183 .filter(line => line);
184 console.log(coloredLines.join('\n'));
185 return patch;
186};
187
188// Convert an array param (expected format "--foo bar baz")
189// to also accept comma input (e.g. "--foo bar,baz")

Callers 1

runFunction · 0.70

Calls 2

joinMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected