Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diff2html-cli

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff2html-cli - npm Package Compare versions

Comparing version 1.4.6-rc.3 to 1.5.0-master.398363a

lib/cli.d.ts

81

package.json
{
"name": "diff2html-cli",
"version": "1.4.6-rc.3",
"homepage": "https://www.github.com/rtfpessoa/diff2html-cli",
"version": "1.5.0-master.398363a",
"homepage": "https://diff2html.xyz/index.html#cli",
"description": "Fast Diff to colorized HTML",

@@ -35,12 +35,26 @@ "keywords": [

"engines": {
"node": ">=0.12.0"
"node": ">=10.13"
},
"preferGlobal": true,
"scripts": {
"style": "eslint src/*.js",
"coverage": "istanbul cover _mocha -- -u exports -R spec ./test/**/*",
"test": "npm run style && npm run coverage",
"codacy": "npm run coverage && cat ./coverage/lcov.info | codacy-coverage",
"preversion": "npm test",
"postversion": "git push && git push --tags"
"eslint": "eslint --ignore-path .gitignore \"**/*.{js,jsx,ts,tsx,json}\"",
"lint:check": "yarn run eslint",
"lint:fix": "yarn run eslint --fix",
"prettier": "prettier --ignore-path .gitignore '**/*.+(js|jsx|ts|tsx|json|css|html|md|mdx)'",
"format:check": "yarn run prettier --check",
"format:fix": "yarn run prettier --write",
"build": "yarn run build:es5",
"build:es5": "rm -rf lib; tsc -p tsconfig.json --outDir lib",
"build:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
"build:toc": "yarn run build:toc-base README.md",
"test": "is-ci 'test:coverage' 'test:watch'",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"coverage:open": "yarn run test:coverage && open ./coverage/index.html",
"coverage:push": "cat ./coverage/lcov.info | codacy-coverage",
"validate": "yarn run format:check && yarn run lint:check && yarn run build && yarn run test:coverage",
"fix": "yarn run format:fix && yarn run lint:fix",
"preversion": "yarn run validate",
"version": "git add -A package.json"
},

@@ -50,19 +64,36 @@ "bin": {

},
"main": "./src/main.js",
"main": "./lib/diff2html.js",
"types": "./lib/diff2html.d.ts",
"dependencies": {
"copy-paste": "^1.3.0",
"diff2html": "^2.0.0-rc.9",
"extend": "^3.0.0",
"open": "0.0.5",
"request": "^2.73.0",
"yargs": "^4.8.0"
"clipboardy": "^2.1.0",
"diff2html": "3.0.0-master.df4481f",
"open": "^7.0.0",
"request": "^2.88.0",
"yargs": "^15.0.2"
},
"devDependencies": {
"codacy-coverage": "^1.1.3",
"eslint": "^3.0.1",
"eslint-plugin-promise": "^1.3.2",
"eslint-plugin-standard": "^1.3.2",
"istanbul": "^0.4.4",
"jscs": "^3.0.6",
"mocha": "^2.5.3"
"@types/hogan.js": "^3.0.0",
"@types/jest": "24.9.0",
"@types/node": "13.1.8",
"@types/request": "2.48.4",
"@typescript-eslint/eslint-plugin": "2.16.0",
"@typescript-eslint/parser": "2.16.0",
"codacy-coverage": "3.4.0",
"eslint": "6.8.0",
"eslint-config-prettier": "6.9.0",
"eslint-plugin-import": "2.20.0",
"eslint-plugin-jest": "23.6.0",
"eslint-plugin-json": "2.0.1",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-optimize-regex": "1.1.7",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-sonarjs": "0.5.0",
"husky": "4.0.10",
"is-ci-cli": "2.0.0",
"jest": "24.9.0",
"lint-staged": "9.5.0",
"markdown-toc": "^1.2.0",
"prettier": "1.19.1",
"ts-jest": "24.3.0",
"typescript": "3.7.5"
},

@@ -72,5 +103,5 @@ "license": "MIT",

"bin",
"src",
"dist"
"lib",
"template.html"
]
}
# diff2html-cli
[![Codacy Code Badge](https://api.codacy.com/project/badge/grade/e6139937d72f40ed8b3920d53c74298a)](https://www.codacy.com/app/Codacy/diff2html-cli)
[![Codacy Coverage Badge](https://api.codacy.com/project/badge/coverage/e6139937d72f40ed8b3920d53c74298a)](https://www.codacy.com/app/Codacy/diff2html-cli)
[![Codacy Quality Badge](https://api.codacy.com/project/badge/Grade/e6139937d72f40ed8b3920d53c74298a)](https://www.codacy.com/app/rtfpessoa/diff2html-cli?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html-cli&utm_campaign=Badge_Grade)
[![Codacy Coverage Badge](https://api.codacy.com/project/badge/Coverage/e6139937d72f40ed8b3920d53c74298a)](https://www.codacy.com/app/rtfpessoa/diff2html-cli?utm_source=github.com&utm_medium=referral&utm_content=rtfpessoa/diff2html-cli&utm_campaign=Badge_Coverage)
[![Circle CI](https://circleci.com/gh/rtfpessoa/diff2html-cli.svg?style=svg)](https://circleci.com/gh/rtfpessoa/diff2html-cli)
[![Dependency Status](https://dependencyci.com/github/rtfpessoa/diff2html/badge)](https://dependencyci.com/github/rtfpessoa/diff2html)

@@ -12,39 +11,53 @@ [![npm](https://img.shields.io/npm/v/diff2html-cli.svg)](https://www.npmjs.com/package/diff2html-cli)

[![node](https://img.shields.io/node/v/diff2html-cli.svg)]()
[![npm](https://img.shields.io/npm/l/diff2html-cli.svg)]()
[![node](https://img.shields.io/node/v/diff2html-cli.svg)]() [![npm](https://img.shields.io/npm/l/diff2html-cli.svg)]()
[![npm](https://img.shields.io/npm/dm/diff2html-cli.svg)](https://www.npmjs.com/package/diff2html-cli)
[![Gitter](https://badges.gitter.im/rtfpessoa/diff2html.svg)](https://gitter.im/rtfpessoa/diff2html?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
Diff to Html generates pretty HTML diffs from git diff output in your terminal
Diff to Html generates pretty HTML diffs from unified and git diff output in your terminal
## Features
## Table of Contents
* `line-by-line` and `side-by-side` diff
<!-- toc -->
* new and old line numbers
- [Features](#features)
- [Online Example](#online-example)
- [Distributions](#distributions)
- [Setup](#setup)
- [Usage](#usage)
- [Custom HTML wrapper template](#custom-html-wrapper-template)
- [Examples:](#examples)
- [Contributions](#contributions)
- [Developing](#developing)
- [License](#license)
- [Thanks](#thanks)
* inserted and removed lines
<!-- tocstop -->
* GitHub like style
## Features
* Code syntax highlight
- Unified diff and Git diff input
* Line similarity matching
- `line-by-line` and `side-by-side` diff
## Online Example
- new and old line numbers
> Go to [Diff2HTML](http://rtfpessoa.github.io/diff2html/)
- inserted and removed lines
## Distributions
- GitHub like style
* [WebJar](http://www.webjars.org/)
- Code syntax highlight
* [Node Module](https://www.npmjs.org/package/diff2html)
- Line similarity matching
* [Bower Package](http://bower.io/search/?q=diff2html)
## Online Example
* [Node CLI](https://www.npmjs.org/package/diff2html-cli)
> Go to [Diff2HTML](https://diff2html.xyz/)
* Manually download and import `rtfpessoa/diff2html/dist/diff2html.min.js` into your page
## Distributions
- [NPM CLI](https://www.npmjs.org/package/diff2html-cli)
- [NPM / Node.js library [ES5 & ES6]](https://github.com/rtfpessoa/diff2html)
- [CDNJS](https://cdnjs.com/libraries/diff2html)
- [WebJar](http://www.webjars.org/)
## Setup

@@ -56,49 +69,108 @@

Usage: diff2html [options] -- [diff args]
Usage: diff2html [options] -- [diff args]
Options:
-s, --style Output style [string] [choices: "line", "side"] [default: "line"]
--su, --summary Show files summary [string] [choices: "closed", "open", "hidden"] [default: "closed"]
--lm, --matching Diff line matching type [string] [choices: "lines", "words", "none"] [default: "none"]
--lmt, --matchWordsThreshold Diff line matching word threshold [string] [default: "0.25"]
--lmm, --matchingMaxComparisons Diff line matching maximum line comparisons of a block of changes [default: 2500]
-f, --format Output format [string] [choices: "html", "json"] [default: "html"]
-d, --diff Diff style [string] [choices: "word", "char"] [default: "word"]
-i, --input Diff input source [string] [choices: "file", "command", "stdin"] [default: "command"]
-o, --output Output destination [string] [choices: "preview", "stdout"] [default: "preview"]
-u, --diffy Upload to diffy.org [string] [choices: "browser", "pbcopy", "print"]
-F, --file Send output to file (overrides output option) [string]
--version Show version number [boolean]
-h, --help Show help [boolean]
| flag | alias | description | choices | default |
| ----- | ------------------------ | -------------------------------------------------------------------------- | ---------------------------- | --------- |
| -s | --style | Output style | `line`, `side` | `line` |
| --sc | --synchronisedScroll | Synchronised horizontal scroll | `true`, `false` | `true` |
| --hc | --highlightCode | Highlight code | `true`, `false` | `true` |
| --su | --summary | Show files summary | `closed`, `open`, `hidden` | `closed` |
| --d | --diffStyle | Diff style | `word`, `char` | `word` |
| --lm | --matching | Diff line matching type | `lines`, `words`, `none` | `none` |
| --lmt | --matchWordsThreshold | Diff line matching word threshold | | `0.25` |
| --lmm | --matchingMaxComparisons | Diff line matching maximum line comparisons of a block of changes | `2500` |
| --hwt | --htmlWrapperTemplate | Path to custom template to be rendered when using the `html` output format | _[string]_ |
| -f | --format | Output format | `html`, `json` | `html` |
| -i | --input | Diff input source | `file`, `command`, `stdin` | `command` |
| -o | --output | Output destination | `preview`, `stdout` | `preview` |
| -u | --diffy | Upload to diffy.org | `browser`, `pbcopy`, `print` | |
| -F | --file | Send output to file (overrides output option) | _[string]_ | |
| --ig | --ignore | Ignore particular files from the diff | _[string]_ | |
| -v | --version | Show version number | | |
| -h | --help | Show help | | |
Examples:
diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1
-> diff last commit, line by line, word comparison between lines,previewed
in the browser and input from git diff command
diff2html -i file -- my-file-diff.diff
-> reading the input from a file
diff2html -f json -o stdout -- -M HEAD~1
-> print json format to stdout
diff2html -F my-pretty-diff.html -- -M HEAD~1
-> print to file
### Custom HTML wrapper template
© 2014 rtfpessoa
For support, check out https://github.com/rtfpessoa/diff2html-cli
The template is a very based on a simple replace of several placeholders as coded
https://github.com/rtfpessoa/diff2html-cli/blob/master/src/cli.ts#L40
> NOTE: notice the `--` in the examples
To provide a custom template you need to make sure you have the following comments and imports in your HTML, exactly as
they are here:
- Inside the `<head>` tag
```
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css" />
<!--diff2html-css-->
<!--diff2html-js-ui-->
<script>
document.addEventListener("DOMContentLoaded", () => {
const targetElement = document.getElementById("diff");
const diff2htmlUi = new Diff2HtmlUI(targetElement);
//diff2html-fileListToggle
//diff2html-synchronisedScroll
//diff2html-highlightCode
});
</script>
```
- Inside the `<body>` tag
```
<div id="diff">
<!--diff2html-diff-->
</div>
```
### Examples:
`diff2html -s line -f html -d word -i command -o preview -- -M HEAD~1`
- diff last commit, line by line, word comparison between lines, previewed in the browser and input from git diff
command
`diff2html -i file -- my-file-diff.diff`
- reading the input from a file
`diff -u file1.txt file2.txt | diff2html -i stdin`
- reading diff from stdin
`diff2html -f json -o stdout -- -M HEAD~1`
- print json format to stdout
`diff2html -F my-pretty-diff.html -- -M HEAD~1`
- print to file
`diff2html -F my-pretty-diff.html --hwt my-custom-template.html -- -M HEAD~1`
- print to file using custom markup templates can include the following variables
`diff2html --ig package-lock.json --ig yarn.lock`
- Ignore `package-lock.json` and `yarn.lock` from the generated diff
_NOTE_: notice the `--` in the examples
## Contributions
This is a developer friendly project, all the contributions are welcome.
To contribute just send a pull request with your changes following the guidelines described in `CONTRIBUTING.md`.
I will try to review them as soon as possible.
This is a developer friendly project, all the contributions are welcome. To contribute just send a pull request with
your changes following the guidelines described in `CONTRIBUTING.md`. I will try to review them as soon as possible.
## Developing
Make some changes, `yarn build` and then `./bin/diff2html` 😉
## License
Copyright 2014 Rodrigo Fernandes. Released under the terms of the MIT license.
Copyright 2014-2019 Rodrigo Fernandes. Released under the terms of the MIT license.
## Thanks
This project is inspired in [pretty-diff](https://github.com/scottgonzalez/pretty-diff) by [Scott González](https://github.com/scottgonzalez).
This project is inspired in [pretty-diff](https://github.com/scottgonzalez/pretty-diff) by
[Scott González](https://github.com/scottgonzalez).
---

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc