Socket
Socket
Sign inDemoInstall

@putout/git-status-porcelain

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @putout/git-status-porcelain

parse git status --porclain output with a pleasure


Version published
Weekly downloads
3.5K
increased by10.28%
Maintainers
1
Install size
7.77 kB
Created
Weekly downloads
 

Readme

Source

Porcelain License NPM version Build Status Coverage

Parse git status --porcelain output with a pleasure.

Install

npm i @putout/git-status-porcelain

How to use?

porcelain can be used in simpified mode, when you just need names of modified files (added, deleted, works as well):

const porcelain = require('@putout/git-status-porcelain');

porcelain({
    modified: true,
    untracked: true,
});

// returns
[
    'README.md',
    '1.js',
];

But you can get break porcelain into pieces as well 😉:

const porcelain = require('@putout/git-status-porcelain');
const {
    run,
    parse,
    pick,
    getNames,
} = porcelain;

// run git status --porcelain
const stdout = run();
// returns
' M README.md\n?? 1.js\n';

const files = parse(stdout);
// returns
[{name: 'README.md', mode: ' M '}, {name: '1.js', mode: '?'}];

const modifiedFiles = pick(files, {
    modified: false,
    untracked: false,
    deleted: false,
    added: false,
    renamed: false,
    unstaged: false,
});
// returns
[{name: 'README.md', mode: ' M '}];

getNames(modifiedFiles);
// returns
['README.md'];

License

MIT

Keywords

FAQs

Last updated on 14 Jun 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc