Skip to content

Commit 342ffcb

Browse files
committed
upgrade and add colorScheme
1 parent b638c9f commit 342ffcb

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
},
8282
"dependencies": {
8383
"clipboardy": "^3.0.0",
84-
"diff2html": "^3.4.19",
84+
"diff2html": "^3.4.46",
8585
"node-fetch": "^3.3.2",
8686
"open": "^9.1.0",
8787
"yargs": "^17.6.0"

src/__tests__/main-tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('cli', () => {
5050
maxLineSizeInBlockForComparison: 200,
5151
outputFormat: 'line-by-line',
5252
renderNothingWhenEmpty: false,
53+
colorScheme: 'auto',
5354
},
5455
{
5556
diffyType: undefined,

src/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function parseArgv(argv: Argv): [Diff2HtmlConfig, Configuration] {
3434
renderNothingWhenEmpty: argv.renderNothingWhenEmpty,
3535
maxLineSizeInBlockForComparison: argv.maxLineSizeInBlockForComparison,
3636
maxLineLengthHighlight: argv.maxLineLengthHighlight,
37+
colorScheme: argv.colorScheme,
3738
};
3839

3940
const defaultPageTitle = 'Diff to HTML by rtfpessoa';

src/yargs.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import yargs from 'yargs';
2+
import { ColorSchemeType } from 'diff2html/lib/types.js';
23

34
import {
45
StyleType,
@@ -35,6 +36,7 @@ export type Argv = {
3536
title?: string;
3637
ignore?: string[];
3738
extraArguments: string[];
39+
colorScheme: ColorSchemeType;
3840
};
3941

4042
const defaults: Argv = {
@@ -59,6 +61,7 @@ const defaults: Argv = {
5961
htmlWrapperTemplate: undefined,
6062
title: undefined,
6163
extraArguments: [],
64+
colorScheme: ColorSchemeType.AUTO,
6265
};
6366

6467
type ArgvChoices = {
@@ -70,6 +73,7 @@ type ArgvChoices = {
7073
input: ReadonlyArray<InputType>;
7174
output: ReadonlyArray<OutputType>;
7275
diffy: ReadonlyArray<DiffyType>;
76+
colorScheme: ReadonlyArray<ColorSchemeType>;
7377
};
7478

7579
const choices: ArgvChoices = {
@@ -81,6 +85,7 @@ const choices: ArgvChoices = {
8185
input: ['file', 'command', 'stdin'],
8286
output: ['preview', 'stdout'],
8387
diffy: ['browser', 'pbcopy', 'print'],
88+
colorScheme: [ColorSchemeType.AUTO, ColorSchemeType.DARK, ColorSchemeType.LIGHT],
8489
};
8590

8691
export async function setup(): Promise<Argv> {
@@ -229,6 +234,12 @@ export async function setup(): Promise<Argv> {
229234
type: 'array',
230235
default: defaults.ignore,
231236
})
237+
.option('colorScheme', {
238+
alias: 'cs',
239+
describe: 'Color scheme of HTML output',
240+
choices: choices.colorScheme,
241+
default: defaults.colorScheme,
242+
})
232243
.example(
233244
'diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1',
234245
'diff last commit, line by line, word comparison between lines,' +

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,15 +2331,15 @@ diff-sequences@^29.4.3:
23312331
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.4.3.tgz#9314bc1fabe09267ffeca9cbafc457d8499a13f2"
23322332
integrity sha512-ofrBgwpPhCD85kMKtE9RYFFq6OC1A89oW2vvgWZNCwxrUpRUILopY7lsYyMDSjc8g6U6aiO0Qubg6r4Wgt5ZnA==
23332333

2334-
diff2html@^3.4.19:
2335-
version "3.4.35"
2336-
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-3.4.35.tgz#75b83c0a7edd8b9521db9bebf8c657cd57f52d3e"
2337-
integrity sha512-+pKs1BrA7l8DAwY33awHyznE3iuTIo58xmINmDBUwGsnou2KvBoSr6dAa6AvQAM7SH+nGtuOKNXmxumgbGp/Pw==
2334+
diff2html@^3.4.46:
2335+
version "3.4.46"
2336+
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-3.4.46.tgz#55344db9c9315787944357621a93659e92fcf8d9"
2337+
integrity sha512-z1SkrH7jDLfmsOYgwJmGiDTdzsbpw7p4vx084kNzeYqER+/Kqp8+v/L7lMsIWpFzlX3NaJDJna280Y/HFqel+Q==
23382338
dependencies:
23392339
diff "5.1.0"
23402340
hogan.js "3.0.2"
23412341
optionalDependencies:
2342-
highlight.js "11.6.0"
2342+
highlight.js "11.8.0"
23432343

23442344
diff@5.1.0:
23452345
version "5.1.0"
@@ -3158,10 +3158,10 @@ has@^1.0.3:
31583158
dependencies:
31593159
function-bind "^1.1.1"
31603160

3161-
highlight.js@11.6.0:
3162-
version "11.6.0"
3163-
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.6.0.tgz#a50e9da05763f1bb0c1322c8f4f755242cff3f5a"
3164-
integrity sha512-ig1eqDzJaB0pqEvlPVIpSSyMaO92bH1N2rJpLMN/nX396wTpDA4Eq0uK+7I/2XG17pFaaKE0kjV/XPeGt7Evjw==
3161+
highlight.js@11.8.0:
3162+
version "11.8.0"
3163+
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.8.0.tgz#966518ea83257bae2e7c9a48596231856555bb65"
3164+
integrity sha512-MedQhoqVdr0U6SSnWPzfiadUcDHfN/Wzq25AkXiQv9oiOO/sG0S7XkvpFIqWBl9Yq1UYyYOOVORs5UW2XlPyzg==
31653165

31663166
hogan.js@3.0.2:
31673167
version "3.0.2"

0 commit comments

Comments
 (0)