mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-23 17:05:26 +00:00
b3cd3c5061
- scope service permission checks to the active organization (#5635) - check backup and volume backup destinations against the organization, confine certificate paths to CERTIFICATES_PATH, validate compose branches (#5541) - send git provider tokens through an http extraHeader instead of the clone URL so submodule URLs and build logs never contain them (#5618) - send the build log tail in build failure notifications (#5557)
31 lines
967 B
TypeScript
31 lines
967 B
TypeScript
import { quote } from "shell-quote";
|
|
import { ExecError } from "../process/ExecError";
|
|
import { execAsync, execAsyncRemote } from "../process/execAsync";
|
|
|
|
const LOG_TAIL_LINES = 30;
|
|
const FALLBACK_MESSAGE = "Error building";
|
|
|
|
export const formatBuildLogTail = (log: string, maxLines = LOG_TAIL_LINES) =>
|
|
log.trim().split("\n").slice(-maxLines).join("\n").trim();
|
|
|
|
// ExecError.message no longer carries the build output; the log tail does.
|
|
export const getBuildErrorMessage = async (
|
|
error: unknown,
|
|
logPath: string,
|
|
serverId?: string | null,
|
|
): Promise<string> => {
|
|
if (!(error instanceof ExecError)) {
|
|
return (error instanceof Error && error.message) || FALLBACK_MESSAGE;
|
|
}
|
|
|
|
try {
|
|
const command = `tail -n ${LOG_TAIL_LINES} ${quote([logPath])}`;
|
|
const { stdout } = serverId
|
|
? await execAsyncRemote(serverId, command)
|
|
: await execAsync(command);
|
|
return formatBuildLogTail(stdout) || FALLBACK_MESSAGE;
|
|
} catch {
|
|
return FALLBACK_MESSAGE;
|
|
}
|
|
};
|