1Panel/frontend/src/utils/docker.ts

29 lines
875 B
Go
Raw Normal View History

import { isJson } from './util';
export function formatImageStdout(stdout: string) {
let lines = stdout.split('\r\n');
for (let i = 0; i < lines.length; i++) {
if (isJson(lines[i])) {
const data = JSON.parse(lines[i]);
2023-03-14 06:28:03 +00:00
if (data.errorDetail || data.error) {
lines[i] = data.errorDetail || data.errorDetail;
lines[i] = data.error || data.error;
continue;
}
2023-02-23 03:39:47 +00:00
if (data.stream) {
lines[i] = data.stream;
continue;
}
if (data.id) {
lines[i] = data.id + ': ' + data.status;
} else {
lines[i] = data.status;
}
if (data.progress) {
lines[i] = lines[i] + data.progress;
}
}
}
return lines.join('\r\n');
}