Skip to content

Commit

Permalink
diff by word
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev committed Jul 5, 2024
1 parent 38dbacf commit 7532a9e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions apps/cli/src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -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}`,
Expand Down

0 comments on commit 7532a9e

Please sign in to comment.