gitwrap
v1.1.0
Published
Simple Git wrapper that doesn't get in the way
Downloads
4
Readme
gitwrap
Simple Git wrapper that doesn't get in the way.
Gitwrap provides a flexible way to use git from nodejs, without attempting to wrap common operations using JavaScript constructs.
var gitwrap = require('gitwrap');
var git = gitwrap.create('path/to/my/repo');
git.execute('log --pretty=oneline -2', function(error, stdout, stderr) {
if(error) throw error;
console.log(stdout);
});
Installation
Install gitwrap
by running:
$ npm install --save gitwrap
Documentation
gitwrap.create(String directory)
Create an instance of gitwrap
around a directory that happens to be a git repository.
var git = gitwrap.create('path/to/my/repo');
git#execute(String command, Function callback)
Execute a git command in the selected repository.
An error with a code ENOGIT
will be returned if git
was not found in the system.
var git = gitwrap.create('path/to/my/repo');
git.execute('log --pretty=oneline -2', function(error, stdout, stderr) {
if(error) throw error;
console.log(stdout);
console.log(stderr);
});
git#isGitRepository(Function callback)
Check that the selected directory is indeed a git repository.
var git = gitwrap.create('path/to/my/repo');
git.isGitRepository(function(isGitRepository) {
if(isGitRepository) {
console.log('path/to/my/repo is a git repository!');
} else {
console.log('path/to/my/repo is not a git repository!');
}
});
Tests
Run the test suite by doing:
$ gulp test
Contribute
- Issue Tracker: github.com/jviotti/gitwrap/issues
- Source Code: github.com/jviotti/gitwrap
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
Support
If you're having any problem, please raise an issue on GitHub.
ChangeLog
v1.1.0
- Change git not found error code to
ENOGIT
. - Improve unit testing.
License
The project is licensed under the MIT license.