New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

g-status

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

g-status

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

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
128K
increased by14.13%
Maintainers
1
Weekly downloads
 
Created
Source

g-status

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

Package Version Downloads Status Build Status: Linux Coverage Status

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 = 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 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.

License

MIT © Lufty Wiranda

Keywords

FAQs

Package last updated on 26 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc