Skip to content

Commit 6f21e24

Browse files
committed
Add summary configuration
1 parent 5c5c605 commit 6f21e24

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Diff to Html generates pretty HTML diffs from git diff output in your terminal
5555

5656
Options:
5757
-s, --style Output style [string] [choices: "line", "side"] [default: "line"]
58-
--su, --summary Show files summary [boolean] [default: "true"]
58+
--su, --summary Show files summary [string] [choices: "closed", "open", "hidden"] [default: "closed"]
5959
--lm, --matching Diff line matching type [string] [choices: "lines", "words", "none"] [default: "none"]
6060
--lmt, --matchWordsThreshold Diff line matching word threshold [string] [default: "0.25"]
6161
-f, --format Output format [string] [choices: "html", "json"] [default: "html"]

dist/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<script>
2424
$(document).ready(function() {
2525
var diff2htmlUi = new Diff2HtmlUI();
26-
diff2htmlUi.fileListCloseable('#diff', false);
26+
//diff2html-fileListCloseable
2727
diff2htmlUi.highlightCode('#diff');
2828
});
2929
</script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff2html-cli",
3-
"version": "1.4.3",
3+
"version": "1.4.4",
44
"homepage": "https://www.github.com/rtfpessoa/diff2html-cli",
55
"description": "Fast Diff to colorized HTML",
66
"keywords": [

src/cli.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,23 @@
7575
config.outputFormat = 'line-by-line';
7676
}
7777

78-
if (baseConfig.summary) {
78+
if (baseConfig.summary === 'hidden') {
79+
config.showFiles = false;
80+
} else {
7981
config.showFiles = true;
82+
config.showFilesOpen = baseConfig.summary === 'open';
8083
}
8184

8285
var htmlContent = Diff2Html.getPrettyHtml(jsonContent, config);
83-
return callback(null, that._prepareHTML(htmlContent));
86+
return callback(null, that._prepareHTML(htmlContent, config.showFilesOpen));
8487
} else if (baseConfig.format === 'json') {
8588
return callback(null, JSON.stringify(jsonContent));
8689
}
8790

8891
return callback(new Error('Wrong output format `' + baseConfig.format + '`!'));
8992
};
9093

91-
Diff2HtmlInterface.prototype._prepareHTML = function(content) {
94+
Diff2HtmlInterface.prototype._prepareHTML = function(content, showFilesOpen) {
9295
var templatePath = path.resolve(__dirname, '..', 'dist', 'template.html');
9396
var template = utils.readFileSync(templatePath);
9497

@@ -101,6 +104,7 @@
101104
return template
102105
.replace('<!--diff2html-css-->', '<style>\n' + cssContent + '\n</style>')
103106
.replace('<!--diff2html-js-ui-->', '<script>\n' + jsUiContent + '\n</script>')
107+
.replace('//diff2html-fileListCloseable', 'diff2htmlUi.fileListCloseable("#diff", ' + showFilesOpen + ');')
104108
.replace('<!--diff2html-diff-->', content);
105109
};
106110

src/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ var argv = yargs.usage('Usage: diff2html [options] -- [diff args]')
2828
'su': {
2929
alias: 'summary',
3030
describe: 'Show files summary',
31-
type: 'boolean',
32-
default: 'true'
31+
type: 'string',
32+
choices: ['closed', 'open', 'hidden'],
33+
default: 'closed'
3334
}
3435
})
3536
.options({

0 commit comments

Comments
 (0)