# g-status

> Get the change between index (or staging-area) and working directory of a `git` repository

Latest version **2.0.2** (published 2018-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install g-status
pnpm add g-status
yarn add g-status
bun add g-status
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2018-01-26 |
| First published | 2018-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lufty Wiranda |
| Maintainers | luftywiranda13 |
| Keywords | git-status, git, index-area, staged, staging-area, staging, status, work-tree, working-directory, worktree |

## Links

- npm: https://www.npmjs.com/package/g-status
- Repository: https://github.com/luftywiranda13/g-status
- Homepage: https://github.com/luftywiranda13/g-status#readme
- Issues: https://github.com/luftywiranda13/g-status/issues
- npm.io page: https://npm.io/package/g-status

## Dependencies (3)

- [arrify](https://npm.io/package/arrify.md) ^1.0.1
- [matcher](https://npm.io/package/matcher.md) ^1.0.0
- [simple-git](https://npm.io/package/simple-git.md) ^1.85.0

## Recent versions

- 2.0.2 (latest) — 2018-01-26
- 2.0.1 — 2018-01-26
- 2.0.0 — 2018-01-26
- 1.1.2 — 2018-01-24
- 1.1.1 — 2018-01-23
- 1.1.0 — 2018-01-23
- 1.0.1 — 2018-01-22
- 1.0.0 — 2018-01-21

## README

# g-status

> Get the change between index (or staging-area) and working directory of a `git` repository

[![Package Version](https://img.shields.io/npm/v/g-status.svg?style=flat-square)](https://www.npmjs.com/package/g-status)
[![Downloads Status](https://img.shields.io/npm/dm/g-status.svg?style=flat-square)](https://npm-stat.com/charts.html?package=g-status&from=2016-04-01)
[![Build Status: Linux](https://img.shields.io/travis/luftywiranda13/g-status/master.svg?style=flat-square)](https://travis-ci.org/luftywiranda13/g-status)
[![Coverage Status](https://img.shields.io/codecov/c/github/luftywiranda13/g-status/master.svg?style=flat-square)](https://codecov.io/gh/luftywiranda13/g-status)

Think of `git status` or `git status --porcelain`, but returns a _ready-to-consume_ result.

## Why

* Maintained
* Accepts simple [wildcard matching](https://github.com/sindresorhus/matcher) patterns
* Promise API
* Ability to get specific results based on status codes
* Knows which files are partially/fully-staged

## Installation

```sh
npm install g-status
```

## Usage

```sh
$ git status --porcelain

A  .travis.yml  # fully-staged
MM index.js     # partially-staged
 M readme.md    # unstaged
```

```js
const gStatus = require('g-status');

gStatus().then(res => {
  console.log(res);
  /*
    [
      { path: '.travis.yml', index: 'A', workingTree: ' ' },
      { path: 'index.js', index: 'M', workingTree: 'M' },
      { path: 'readme.md', index: ' ', workingTree: 'M' }
    ]
  */
});

gStatus({ path: ['!*.js', '!*.md'] }).then(res => {
  console.log(res);
  //=> [{ path: '.travis.yml', index: 'A', workingTree: ' ' }]
});

// Files marked as `Modified` or `Added` in the staging area,
gStatus({ index: 'MA' }).then(res => {
  console.log(res);
  /*
    [
      { path: '.travis.yml', index: 'A', workingTree: ' ' },
      { path: 'index.js', index: 'M', workingTree: 'M' },
    ]
  */
});

// Files that arenʼt changed in the working tree
gStatus({ workingTree: ' ' }).then(res => {
  console.log(res);
  //=> [{ path: '.travis.yml', index: 'A', workingTree: ' ' }]
});

// Files that are marked as `Modified` both in staging area and working tree
gStatus({ index: 'M', workingTree: 'M' }).then(res => {
  console.log(res);
  //=> [{ path: 'index.js', index: 'M', workingTree: 'M' }]
});
```

See the [tests](https://github.com/luftywiranda13/g-status/blob/master/test.js) for more usage examples and expected matches.

## API

### gStatus([options])

Returns `Promise<{ path: string, index: string, workingTree: string }[]>`.

#### options

Type: `Object`

##### cwd

Type: `string`<br />
Default: `process.cwd()`

Current working directory.

##### path

Type: `string` | `string[]`<br />
Default: `*`

Use `*` to match zero or more characters. A pattern starting with `!` will be negated.

##### index

Type: `string`<br />
Default: `*`

String of `git` status codes of the index/staging-area, See [Short Format](https://git-scm.com/docs/git-status#_short_format).<br />
One difference is that `*` will match all value here.

##### workingTree

Type: `string`<br />
Default: `*`

String of `git` status codes of the working tree, See [Short Format](https://git-scm.com/docs/git-status#_short_format).<br />
One difference is that `*` will match all value here.

## Related

* [simple-git](https://github.com/steveukx/git-js) – Simple git interface for Node.js
* [staged-git-files](https://github.com/mcwhittemore/staged-git-files) – Abandoned, the latest commit was 3 years ago

## License

MIT &copy; [Lufty Wiranda](https://www.luftywiranda.com)

---
_Source: https://npm.io/package/g-status · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
