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

nodegit-probablycorey

v2.0.0-beta.2

Published

Node.js libgit2 asynchronous native bindings

Downloads

12

Readme

NodeGit

Node bindings to the libgit2 project.

Build
Status

Stable: 0.1.4

Maintained by Tim Branyen @tbranyen, Michael Robinson @codeofinterest, and Nick Kallen @nk, with help from awesome contributors!

API Documentation.

http://www.nodegit.org/nodegit/

Getting started.

NodeGit will work on most systems out-of-the-box without any native dependencies.

npm install nodegit

If you encounter problems while installing, you should try the Building from source instructions below.

Building from source.

Minimum dependencies:

If you wish to help contribute to nodegit it is useful to build locally.

# Fetch this project.
git clone git://github.com/tbranyen/nodegit.git

# Enter the repository.
cd nodegit

# Installs the template engine, run the code generation script, and build.
npm install

If you encounter errors, you most likely have not configured the dependencies correctly.

Installing dependencies:

Mac OS X

Linux

Using APT in Ubuntu:

sudo apt-get install build-essential

Using Pacman in Arch Linux:

sudo pacman -S base-devel

Windows

You may have to add a build flag to the installation process to successfully install. Try first without, if the build fails, try again with the flag.

Allegedly the order in which you install Visual Studio could trigger this error.

npm install nodegit --msvs_version=2013
# Or whatever version you've installed.

API examples.

Cloning a repository and reading a file:

var clone = require("nodegit").Repository.clone;

// Clone a given repository into a specific folder.
clone("https://github.com/nodegit/nodegit", "tmp", null).then(function(repo) {
  // Use a known commit sha from this repository.
  var sha = "59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5";

  // Look up this known commit.
  repo.getCommit(sha).then(function(commit) {
    // Look up a specific file within that commit.
    commit.getEntry("README.md").then(function(entry) {
      // Get the blob contents from the file.
      entry.getBlob().then(function(blob) {
        // Show the name, sha, and filesize in byes.
        console.log(entry.name() + entry.sha() + blob.size() + "b");

        // Show a spacer.
        console.log(Array(72).join("=") + "\n\n");

        // Show the entire file.
        console.log(String(blob));
      });
    });
  });
});

Emulating git log:

var open = require("nodegit").Repository.open;

// Open the repository directory.
open("tmp").then(function(repo) {
  // Open the master branch.
  repo.getMaster().then(function(branch) {
    // Create a new history event emitter.
    var history = branch.history();

    // Create a counter to only show up to 9 entries.
    var count = 0;

    // Listen for commit events from the history.
    history.on("commit", function(commit) {
      // Disregard commits past 9.
      if (++count >= 9) {
        return;
      }

      // Show the commit sha.
      console.log("commit " + commit.sha());

      // Store the author object.
      var author = commit.author();

      // Display author information.
      console.log("Author:\t" + author.name() + " <", author.email() + ">");

      // Show the commit date.
      console.log("Date:\t" + commit.date());

      // Give some space and show the message.
      console.log("\n    " + commit.message());
    });

    // Start emitting events.
    history.start();
  });
});

Unit tests.

You will need to build locally before running the tests. See above.

npm test