https://github.com/bendrucker/git-child
Node utility for running git commands
https://github.com/bendrucker/git-child
Last synced: 3 months ago
JSON representation
Node utility for running git commands
- Host: GitHub
- URL: https://github.com/bendrucker/git-child
- Owner: bendrucker
- License: mit
- Created: 2015-01-04T18:03:30.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-11-13T19:15:14.000Z (over 7 years ago)
- Last Synced: 2025-08-03T07:05:03.546Z (12 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
git-child [](https://travis-ci.org/bendrucker/git-child)
=========
Node utility for running `git` commands via the command line via [`child_process`](http://nodejs.org/api/child_process.html).
## Installing
```bash
$ npm install git-child
```
## API
##### `git.run(command, args, options)` -> `promise`
`git.run` is the low level command that controls creating a child process and returning its output from `stdout` as a promise. `command` is a git command, like `'log'`. `args` can be an `Array` of arguments to be passed to git (`git.run('log', ['-a'])`) or an object to be passed to [argv-formatter](https://github.com/bendrucker/argv-formatter) (`git.run('log', {a: true})`). If `options.spawn` is `true`, the promise will resolve the `ChildProcess` instance so you can manually interact with the stdio streams. Otherwise, it buffers `stdout` using `child_process.execFile` and resolves `stdout`. `options` are passed along to the `child_process`.
### Git Commands
git-child creates sugar methods for all known git methods.
```js
// log the last 3 commits
git.log({
n: 3
})
.then(console.log);
```
Methods with dashes will be camel cased, so `git add--interactive` becomes `git.addInteractive`. To update the list of commands, run `npm run commands`.