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

git-handler

v2.0.1

Published

NPM module for handling git repositories. Makes it easy to add, checkout, branch, clone, commit, pull and push.

Downloads

11

Readme

#git-handler

I created git-handler mostly because I am using webpack to bundle an electron application, and I needed some way to pull down a template structure that is being hosted on github. I tried a lot of the other git modules available, and though they are good they weren't compatible with webpack. Hence, the only (that I know of) git module that works with webpack.

##Usage

Some new features have been added for version 2 including the ability to do git add, git checkout, git clone, git commit, git pull and git push. Again, if you have any ideas or issues please post them to the git repository located here.

import Git from 'git-handler'; // If using ES6 import statement.
const Git = require('git-handler'); // If using ES Vanilla.

const RepoUrl = 'https://github.com/user/repo.git';
const LocalUrl = '/path/to/local/repository/';

/**
 * @method add
 *
 * Called to add changed items to the local repository so they are ready to be staged.
 *
 * @param Path to the local git repository.
 * @param Callback method for when the process completes.
**/
Git.add(LocalUrl, function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log(details.stdout);
  console.log(details.stderr);
});

/**
 * @method checkout
 *
 * Called to checkout a new or existing branch.
 *
 * @param Path to the local git repository.
 * @param Name of the existing or new branch.
 * @param True to force creation of new branch if doesn't exist, false to throw an error.
 * @param Callback method for when the process completes.
**/
Git.checkout(LocalUrl, 'new-branch', true, function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log(details.stdout);
  console.log(details.stderr);
});

/**
 * @method clone
 *
 * Called to clone a repository.
 *
 * @param HTTPS path to the remote repository.
 * @param Path to where on your machine you would like to clone the repository.
 * @param (optional) array of flags to use with the clone command.
 * @param Callback method for when the process completes.
**/
Git.clone(RepoUrl, '/path/to/clone/to', ['-l', '-s'], function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log('YAY! The repository was cloned successfully.');
});

/**
 * @method commit
 *
 * Called to commit unstaged changes to the local repository.
 *
 * @param Path to the local git repository.
 * @param Message to commit with.
 * @param Callback method for when the process completes.
 *
 * NOTE: Commit automatically calls the 'add' method!
**/
Git.commit(LocalUrl, 'Commit message', function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log(details.stdout);
  console.log(details.stderr);
});

/**
 * @method pull
 *
 * Called to pull the latest from the remote repository.
 *
 * @param Path to the local git repository.
 * @param HTTPS path to the remote repository.
 * @param Name of the branch to pull.
 * @param Callback method for when the process completes.
**/
Git.pull(LocalUrl, RepoUrl, 'master', function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log(details.stdout);
  console.log(details.stderr);
});

/**
 * @method push
 *
 * Called to push the staged changes from your local repository to the remote repository.
 *
 * @param Path to the local git repository.
 * @param HTTPS path to the remote repository.
 * @param Name of the branch to push to.
 * @param Credentials object containing { password, userName }
 * @param Callback method for when the process completes.
**/
Git.push(LocalUrl, RepoUrl, 'master', { password: '*****', userName: 'unibrowdev' }, function (details) {
  if (details.err) {
    console.error(details.err);
    return;
  }
  console.log(details.stdout);
  console.log(details.stderr);
});