From b55e807c6256e8f76ee61966408d8bbcdb6239ee Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 10 May 2022 21:12:00 -0700 Subject: [PATCH] Truncate multi-line commit messages in console build info (#180) --- web/pages/_app.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/pages/_app.tsx b/web/pages/_app.tsx index 3504df74..628936f6 100644 --- a/web/pages/_app.tsx +++ b/web/pages/_app.tsx @@ -5,6 +5,10 @@ import Head from 'next/head' import Script from 'next/script' import { usePreserveScroll } from 'web/hooks/use-preserve-scroll' +function firstLine(msg: string) { + return msg.replace(/\r?\n.*/s, '') +} + function printBuildInfo() { // These are undefined if e.g. dev server if (process.env.NEXT_PUBLIC_VERCEL_ENV) { @@ -14,7 +18,7 @@ function printBuildInfo() { let repo = process.env.NEXT_PUBLIC_VERCEL_GIT_REPO_SLUG let sha = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA let url = `https://github.com/${owner}/${repo}/commit/${sha}` - console.info(`Build: ${env} / ${msg || '???'} / ${url}`) + console.info(`Build: ${env} / ${firstLine(msg || '???')} / ${url}`) } }