From 7532a9e47199d6c5ed781607e0ade9766bf0e97f Mon Sep 17 00:00:00 2001 From: Sasha Mysak Date: Fri, 5 Jul 2024 12:09:34 +0200 Subject: [PATCH] diff by word --- apps/cli/src/commands/run.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 354a0ca51..c92e94891 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -453,10 +453,7 @@ export const handleRunCliCommand = async (options: { return { filename: command.newPath, codemodName: command.codemodName, - diff: command.newData - .split("\n") - .map((line) => chalk.bgGreen(line)) - .join("\n"), + diff: chalk.bgGreen(command.newData), }; } @@ -484,17 +481,19 @@ export const handleRunCliCommand = async (options: { }; } - const diffResult = diff.diffLines(command.oldData, command.newData); + const diffResult = diff.diffWords(command.oldData, command.newData); const formattedDiff = diffResult .map((part) => { const color = part.added ? "green" : part.removed ? "red" : "grey"; - return part.value - .split("\n") - .map((line) => chalk[color](line)) - .join("\n"); + + return chalk[color](part.value); + // return part.value + // .split("\n") + // .map((line) => chalk[color](line)) + // .join("\n"); }) - .join("\n"); + .join(""); return { filename: `${command.oldPath}`,