New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

git-diff-clean

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-diff-clean

A slightly cleaner git diff viewer.

latest
npmnpm
Version
1.5.0
Version published
Maintainers
0
Created
Source

git-diff-clean

Cleaner git-diff output for terminal and as node library.

git-diff vs git-diff-clean

  • Link to changes via cmd+click
  • Emoji to visually group changes in the same file
  • Include untracked files
  • Stripped down output

Terminal usage

> npx git-diff-clean -h
Options:
      --version           Show version number                          [boolean]
  -p, --includePlusMinus  Include plus/minus signs in the diff output
                                                       [boolean] [default: true]
  -c, --includeColors     Include colors in the diff output
                                                       [boolean] [default: true]
  -e, --includeEmoji      Include emojis next to file names to visually group
                          them.                        [boolean] [default: true]
  -f, --includeFooter     Include a line as a footer to close out the diff
                          output                       [boolean] [default: true]
  -l, --useLess           Use less as the pager to view output
                                                       [boolean] [default: true]
  -u, --includeUntracked  Include untracked files in the diff output (not used
                          when --cached is on)         [boolean] [default: true]
  -g, --cached            Show staged changes (--cached)
                                                       [boolean] [default: false]
  -h, --help              Show help                                    [boolean]

Or faster via bun with bunx git-diff-clean

And if you like it alias d="bunx git-diff-clean"

Library usage

export type DiffOptions = {
  /* Include plus/minus signs in the diff output */
  includePlusMinus: boolean
  /* Include colors in the diff output */
  includeColors: boolean
  /* Include emojis next to file names to visually group them. */
  includeEmoji: boolean
  /* Include a line as a footer to close out the diff output */
  includeFooter: boolean
  /* Show staged changes */
  cached: boolean
}

/**
 * Get the current git diff as a string.
 *
 * @param options [DiffOptions] - Options for the diff output.
 * @returns [String] git diff string
 */
export function getDiff(options: DiffOptions): string { .. }
/**
 * Open the current git diff in less.
 *
 * @param options [DiffOptions] - Options for the diff output.
 */
function showDiff(options: DiffOptions, useLess: boolean = true) { .. }

Why I built this library

I'm building a personal AI coding assistant that often edits multiple files. I found git-diff is a good way to review those changes but it was a little limited. The two capabilities I wanted are (1) make it a bit easier to read and (2) provide a link in VSCode terminal I can click to go directly to the edit.

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts