g-status
Get the change between index (or staging-area) and working directory of a
git
repository
Think of git status
or git status --porcelain
, but returns a ready-to-consume result.
Why
- Maintained
- Accepts simple wildcard matching patterns
- Promise API
- Ability to get specific results based on status codes
- Knows which files are partially/fully-staged
Installation
npm install g-status
Usage
$ git status --porcelain A .travis.yml # fully-staged MM index.js # partially-staged M readme.md # unstaged
const gStatus = ; ; ; // Files marked as `Modified` or `Added` in the staging area,; // Files that arenʼt changed in the working tree; // Files that are marked as `Modified` both in staging area and working tree;
See the tests for more usage examples and expected matches.
API
gStatus([options])
Returns Promise<{ path: string, index: string, workingTree: string }[]>
.
options
Type: Object
cwd
Type: string
Default: process.cwd()
Current working directory.
path
Type: string
| string[]
Default: *
Use *
to match zero or more characters. A pattern starting with !
will be negated.
index
Type: string
Default: *
String of git
status codes of the index/staging-area, See Short Format.
One difference is that *
will match all value here.
workingTree
Type: string
Default: *
String of git
status codes of the working tree, See Short Format.
One difference is that *
will match all value here.
Related
- simple-git – Simple git interface for Node.js
- staged-git-files – Abandoned, the latest commit was 3 years ago
License
MIT © Lufty Wiranda