MCPcopy Create free account
hub / github.com/devcontainers/cli / colorizePlainText

Function colorizePlainText

src/spec-utils/log.ts:264–276  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

262}
263
264function colorizePlainText(text: string) {
265 const num = /(?<=^|[^A-Za-z0-9_\-\.])[0-9]+(\.[0-9]+)*(?=$|[^A-Za-z0-9_\-\.])/g;
266 let m: RegExpExecArray | null;
267 let lastIndex = 0;
268 const fragments: string[] = [];
269 while (m = num.exec(text)) {
270 fragments.push(text.substring(lastIndex, m.index));
271 fragments.push(color(numberColor, m[0]));
272 lastIndex = num.lastIndex;
273 }
274 fragments.push(text.substr(lastIndex));
275 return fragments.join('');
276}
277
278export function toErrorText(str: string) {
279 return str.split(/\r?\n/)

Callers 1

colorizeFunction · 0.85

Calls 2

colorFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected