From 312562889c6d9ccee7b6594e1879267bbbc5f490 Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk <84377976+nikita-web-ua@users.noreply.github.com> Date: Sat, 29 Jul 2023 20:34:42 +0200 Subject: [PATCH] [ACS-5400] Fix incomplete string escaping (#8721) * [ACS-5400] string escaping fix * [ACS-5400] Unexpected token in json fix --- lib/cli/scripts/changelog.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cli/scripts/changelog.ts b/lib/cli/scripts/changelog.ts index 2dff31ddf2..183b12d35a 100644 --- a/lib/cli/scripts/changelog.ts +++ b/lib/cli/scripts/changelog.ts @@ -109,12 +109,12 @@ function getCommits(options: DiffOptions): Array { let log = shell.exec(command, { cwd: options.dir, silent: true }).toString(); // https://stackoverflow.com/a/13928240/14644447 - log = log.trim().replace(/"/gm, '\\"').replace(/\^@\^/gm, '"'); + log = JSON.stringify(log.trim()).slice(1, -1).replace(/\^@\^/gm, '"'); if (log.endsWith(',')) { log = log.substring(0, log.length - 1); } - return log.split('\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter)); + return log.split('\\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter)); } function commitAuthorAllowed(commit: Commit, authorFilter: string): boolean {