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-lib

v1.6.0

Published

A github library for multiple package uses

Downloads

134

Readme

git-lib

Build Status

A library that contains different methods to be consumed by a node module

Install

To install, simply run

> npm install --save git-lib

Use

To use, require it by

var git = require("git-lib");

Methods

haveFilesToCommit

Resolves if current directory has files to commit, throws if it doesn't

git.haveFilesToCommit().then(function(){
    /** there are files to commit **/
}).catch(function(err){
    if (err === "There are no files to commit"){
        /** there are no files to commit **/
    }
    else {
        /** some error has occured **/
    }
});

add

Attempts to git add a file

git.add("example.file").then(function(){
    /** successfully added **/
}).catch(function(err){
    /** unsuccessful **/
});

getCurrentBranch

Gets the name of the directory's current branch

git.getCurrentBranch().then(function(branchname){
    /** branchname has the name of current branch **/
}).catch(function(err){
    /** throws an error **/
});

showFilesAdded

Show files that has already been added

git.showFilesAdded().then(function(filesAdded){
    /** filesAdded shows, in a string, a list of files added **/
}).catch(function(err){
    /** throws an error**/
});

showFilesModified

Show files in current directory that has been modified (and probably needs to be commited)

git.showFilesModified().then(function(modifiedFiles){
    /** modifiedFiles is an array of files that has been modified **/
}).catch(function(err){
    /** throws an error **/
});

commit

Commits with a string of message and a string of options

git.commmit("message to commit", "--force").then(function(){
    /** commit successful **/
}).catch(function(err){
    /** throws an error **/
});

revert

Takes an array of files, or a string of only one file, and reverts them

git.revert(["file1","file2"]).then(function(){
    /** successfully reverted **/
}).catch(function(err){
    /** throws an error **/
});

isGit

Determines if current directory has git initialized

git.isGit().then(function(){
    /** has git initialized **/
}).catch(function(err){
    /** doesn't have git initialized, and err displays that **/
});

isGitSync

A synchronous version of isGit, so it can be used in an if statement

if (git.isGitSync()){
    /** has git initialized **/
}
else {
    /** doesn't have git initialized **/
}

getFilesCached

Show files that are cached, which are also files that are added

git.getFilesCached().then(function(files){
    /** files is an array list of files that has been added **/
}).catch(function(err){
    /** throws an error **/
});

getBranches

Local

Returns all local branches for the current git repository

git.getBranches.local().then(function(branches){
    /** branches is an array of local branches **/  
}).catch(function(error){
    /** throws an error **/
});

all

Returns all branches, including remote, for the current git repository

git.getBranches.all().then(function(branches){
    /** branches is an array of all branches **/  
}).catch(function(error){
    /** throws an error **/
});

checkout

Changes into branch thisBranch, where thisBranch is passed into the function

git.checkout("thisBranch").then(function(){
    /** successfully checked out into branch *thisBranch* **/
}).catch(function(err){
    /** throws an error **/
});

newBranch

Creates new branch newBranch, where newBranch is passed into the function

git.newBranch("newBranch").then(function(){
    /** new branch *newBranch* was successfully created **/
}).catch(function(err){
    /** throws an error **/
});

deleteBranch

Deletes branch thisbranch, where thisbranch is passed into the function

git.deleteBranch("thisbranch").then(function(){
    /** new branch *thisbranch* was successfully deleted**/
}).catch(function(err){
    /** throws an error **/
});

deleteBranches

Delete multiple branches, using deleteBranch. The array passed into the function is the array of a list of branches to delete

git.deleteBranches(/** array of branches name **/).then(function(result){
    /** result = { success: [ all the successfully deleted branches ], failure: [ all the branches that failed to be deleted ] } **/
});

Versions

1.6.0

  • Added deleteBranches

1.5.0

  • Added deleteBranch

1.4.0

  • Updated to include methods for checkout-cli

1.3.1

  • changed showFilesCached to getFilesCached

1.3.0

  • Added showFilesCached

1.2.3

  • fixed both isGit

1.2.2

  • Added error output with isGit

1.2.1

  • Fixed README bugs

1.2.0

  • Updated with isGit and isGitSync

1.1.0

  • Added README
  • Added showFilesAdded

1.0.0

  • First publish