fake-diff
v1.0.0
Published
Build git-like colorful, command line loggable line diffs
Downloads
329
Readme
fake-diff
fake-diff is a tiny Node.js plugin that you can include in your projects. You can install it via following command:
npm install fake-diff
Usage
Simply compare two strings as the first and second argument:
const fakeDiff = require('fake-diff')
console.log(fakeDiff(oldString, newString))
Example output:
Or you can pass files:
const fs = require('fs')
const fakeDiff = require('fake-diff')
const oldFileContent = fs.readFileSync(__dirname + "/oldFile.txt", "utf-8")
const newFileContent = fs.readFileSync(__dirname + "/newFile.txt", "utf-8")
console.log(fakeDiff(oldFileContent, newFileContent))
Also takes the following options as an object in the third parameter:
fakeDiff(oldFile, newFile, options)
| Option | Type | Default Value |
|--|--|--|
| hideLines | boolean | true |
| maxAdjacentStaticLines | number | 1
Credit
Relies on diff (npm package) to generate line diffs, and chalk for coloring.
Alternatives: git-diff (npm package)
License
MIT