git-print
v1.2.0
Published
Print normalized list of git status files for command line usage.
Downloads
9
Maintainers
Readme
git-print
Print normalized list of git status files for command line usage.
$ git status -s
# Output:
$ M README.md
$ M src/index.js
$ ?? src/index.spec.js
$ git-print
# Output:
$ /path/to/README.md /path/to/src/index.js /path/to/src/index.spec.js
Contents
Installation
yarn
$ yarn add git-print --dev
npm
$ npm install git-print --save-dev
Usage
$ git-print [OPTIONS]
When there are no changes in the current git repository, git-print
exits with status code 1
instead of printing an
empty file list. This allows for streamlined conditional chaining with other commands.
Options
--cwd=<string>
Default: ./
Provide a custom execution path.
--deleted=<boolean>
Default: true
Toggle listing of files with status deleted
.
--staged=<boolean>
Default: true
Toggle listing of staged
files.
--staged-only=<boolean>
Default: true
Shorthand option for listing of staged
files only.
This option makes the output suitable for processing with linting and formatting tools.
Same as manually specifying options:
--staged=true \
--deleted=false \
--unstaged=false \
--untracked=false
--unstaged=<boolean>
Default: true
Toggle listing of unstaged
files.
--untracked=<boolean>
Default: true
Toggle listing of untracked
files.
Examples
Run Prettier formatting on staged files, or format the current directory when no files are staged.
package.json:
{
"scripts": {
"prettier": "yarn prettier --write $(git-print --staged-only || printf '.')"
}
}
Development
Clone this repository and execute:
$ yarn install && yarn run bootstrap
See the list of available commands:
$ yarn run
- Install editor SDKs for Yarn Plug'n'Play installs.
- Execute
yarn dev
to start the local development environment.
Changelog
See the releases page.
Read more
List of similar projects with API usage: