npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

github-diff

v1.3.3

Published

A small utility for getting diffs from github projects

Downloads

860

Readme

github-diff

Get a diff between 2 commits or tags of a github project

Usage

Setup

In order to use github-diff to access a private repository you'll need to create a personal access token and set the environment variable GITHUB_DIFF_TOKEN to the token

You can run the following in the command line or add it your .bashrc

export GITHUB_DIFF_TOKEN=token

Arguments and return values

github-diff takes the following arguments

  • repository: a github repository name and owner split by a /: ex alex-e-leon/github-diff
  • base: a commit hash or tag to diff from
  • head: a commit hash or tag to diff to

github-diff returns a promise that returns the following structure:

[{ filename, patch, header, status, fileA, fileB}, ...]
  • filename: The full path of the file from the base of the repo, ex: /src/my-file.js
  • patch: The patch provided by github for the file. Looks like a regular git formatted patch without the header
  • header: A basic git patch style header. Currently doesn't include commit hashes, but should validate if used with git apply
  • status: The diff status for the file. Returns one of modified, renamed, deleted, added, etc. See git docs for all options
  • fileA: The contents of the base file (if it exists in base)
  • fileB: The contents of the head file (if it exists in head)
  • previousFilename: The previous filename (if the file has been renamed)

Node example

import githubDiff from 'github-diff';
githubDiff('alex-e-leon/github-diff', 'v1.0.0', 'v.1.0.1').then((patches) => {
  console.log(patches);
});

Cli example

node cli.js domain-group/fe-boilerplate-generator v2.3.0 v3.0.0