Skip to content

Commit 685f196

Browse files
authored
Merge pull request #56 from rtfpessoa/fix-diff-by-char
fix: Bring back diff by char
2 parents fb3fa69 + 76f56d7 commit 685f196

File tree

5 files changed

+199
-161
lines changed

5 files changed

+199
-161
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@
5353
"main": "./build/main.js",
5454
"dependencies": {
5555
"clipboardy": "^2.1.0",
56-
"diff2html": "^2.11.2",
56+
"diff2html": "^2.12.1",
5757
"open": "^6.4.0",
5858
"request": "^2.88.0",
5959
"yargs": "^14.0.0"
6060
},
6161
"devDependencies": {
62-
"@types/diff2html": "0.0.5",
6362
"@types/jest": "24.0.18",
6463
"@types/node": "^12.7.2",
6564
"@types/request": "2.48.2",

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export function parseArgv(argv: Argv): [Diff2Html.Options, Configuration] {
88
inputFormat: "diff",
99
outputFormat: argv.style === "side" ? "side-by-side" : "line-by-line",
1010
showFiles: argv.summary !== "hidden",
11+
diffStyle: argv.diffStyle,
1112
matching: argv.matching,
1213
matchWordsThreshold: argv.matchWordsThreshold,
1314
matchingMaxComparisons: argv.matchingMaxComparisons

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type StyleType = "line" | "side";
22
export type SummaryType = "closed" | "open" | "hidden";
3+
export type DiffStyleType = "word" | "char";
34
export type LineMatchingType = "lines" | "words" | "none";
45
export type FormatType = "html" | "json";
56
export type InputType = "file" | "command" | "stdin";

src/yargs.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import * as yargs from "yargs";
22

3-
import { StyleType, SummaryType, LineMatchingType, FormatType, InputType, OutputType, DiffyType } from "./types";
3+
import {
4+
StyleType,
5+
SummaryType,
6+
LineMatchingType,
7+
FormatType,
8+
InputType,
9+
OutputType,
10+
DiffyType,
11+
DiffStyleType
12+
} from "./types";
413

514
export type Argv = {
615
style: StyleType;
716
synchronisedScroll: boolean;
817
highlightCode: boolean;
18+
diffStyle: DiffStyleType;
919
summary: SummaryType;
1020
matching: LineMatchingType;
1121
matchWordsThreshold: number;
@@ -25,6 +35,7 @@ export function setup(): Argv {
2535

2636
const styleChoices: StyleType[] = ["line", "side"];
2737
const summaryChoices: SummaryType[] = ["closed", "open", "hidden"];
38+
const diffStyleChoices: DiffStyleType[] = ["word", "char"];
2839
const matchingChoices: LineMatchingType[] = ["lines", "words", "none"];
2940
const formatChoices: FormatType[] = ["html", "json"];
3041
const inputChoices: InputType[] = ["file", "command", "stdin"];
@@ -68,6 +79,16 @@ export function setup(): Argv {
6879
default: "closed"
6980
}
7081
})
82+
.options({
83+
diff: {
84+
alias: "d",
85+
describe: "Diff style",
86+
nargs: 1,
87+
type: "string",
88+
choices: diffStyleChoices,
89+
default: "word"
90+
}
91+
})
7192
.options({
7293
matching: {
7394
alias: "lm",
@@ -184,6 +205,7 @@ export function setup(): Argv {
184205
...argv,
185206
style: argv.style as StyleType,
186207
summary: argv.summary as SummaryType,
208+
diffStyle: argv.diffStyle as DiffStyleType,
187209
matching: argv.matching as LineMatchingType,
188210
format: argv.format as FormatType,
189211
input: argv.input as InputType,

0 commit comments

Comments
 (0)