Coder Social home page Coder Social logo

staged-git-files's Introduction

Staged Git Files

This module returns an array of staged files and their status acording to git.

Usage

npm install staged-git-files

var sgf = require("staged-git-files");
sgf(function(err, results){
	//WHAT EVER YOU SO PLEASE
});

Example Results

[
	{
		"filename": "package.json",
		"status": "Added"
	},
	{
		"filename": "readme.md",
		"status": "Modified"
	},
	{
		"filename": "index.js",
		"status": "Renamed"
	}
]

Usage as a cli

$ sgf
Added package.json
Modified readme.md
Renamed index.js

API

sgf(filter, callback)

Get a list of staged git files

  • filter: string of git status codes. No spaces
  • callback:
    • err: the error
    • results: file object array.

sgf.getHead(callback)

Get head that will be used in the diff to ID which files are waiting to be staged.

  • callback
    • err: the error
    • head: the git commit id which is aliased to head.

sgf.readFile(filename, [options], callback)

This is a proxy for fs.readFile with one change. The filename will be relative to the sgf.cwd

sgf.debug

Boolean that flips logging on and off. By default this is false. If true, all git commands will be console logged.

sgf.includeContent

If true, include content will add a content or err param to the file object.

  • Default Value: false
  • Content Param: the content of the file staged
  • Err Param: the error message received while trying to read the file.

sgf.cwd

The current working directory. AKA: where the .git folder you care about is.

Default Value: is equal to process.cwd() of your app.g

Statuses

SGF-Status (git status code)

  • Added (A)
  • Copied (C)
  • Deleted (D)
  • Modified (M)
  • Renamed (R)
  • Type-Change (T) [i.e. regular file, symlink, submodule, etc.]
  • Unmerged (U)
  • Unknown (X)

staged-git-files's People

Contributors

imcuttle avatar mcwhittemore avatar romeovs avatar twhitbeck avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.