Thin wrapper around the git binary.
This library provides a very simple wrapper around the git binary.
Install the module with:
npm install git-exec
The library is used by constructing an object which represents a git repository on the system.
The majority of the interaction involves an exec() method which is invoked on instances of such objects. This method is relatively stupid in that we do not try to parse the output or validate commands invoked.
However, we do take care to provide a means to both init / clone git repositories and we set the working directory correctly such that further git commands execute in the correct context.
This method will construct a repo object at the specified directory.
These methods will return a repo object on success as the first argument to the callback passed to them or null on error.
if repo !== null// valid repoelse// an error occurred
var Git = require'git-exec';Gitclonea-repogit 'dir'// NOTE the callback is given a reference to the git repositoryrepoexec'checkout' '-t origin/dev'// ... callback to execute after branch checkout;;
var Git = require'git-exec';Gitinit'my-new-repo' null// ... operations on repo object;
var Git = require'git-exec';Gitinitnull '/path/to/repo'// ... operations on repo object;
As an alternative, init also supports a named repo at a specific path. Thus for a repo named 'my-new-repo' at '/path/to' such that the full path to the repo is /path/to/my-new-repo call init as follows:
var Git = require'git-exec';Gitinit'my-new-repo' '/path/to'// ... operations on repo object;
var Git = require'git-exec';var repo = './path/to/repo';repoexec'pull' null// ... callback to execute after git pull;
Or alternatively, to instantly create a repo and perform some operation:
require'git-exec'repo'./path/to/repo'exec'branch' 'dev'// ... callback to execute;
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Copyright (c) 2013 Alex J Burke Licensed under the MIT license.