You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@putout/git-status-porcelain

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/git-status-porcelain

parse git status --porclain output with a pleasure

3.0.0
latest
Source
npmnpm
Version published
Weekly downloads
4.8K
22.31%
Maintainers
1
Weekly downloads
 
Created
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

read

FAQs

Package last updated on 14 Jun 2023

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