git-exec
This library provides a very simple wrapper around the git binary.
Getting Started
Install the module with: npm install git-exec
Documentation
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.
repo
This method will construct a repo object at the specified directory.
init/clone
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 repo else // an error occurred }
Examples
Cloning a remote repository and checkout of origin/dev
var Git = ;Git;
Intialising a local repository in CWD
var Git = ;Git;
Intialising a local repository at given path
var Git = ;Git;
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 = ;Git;
Using a local git repository
var Git = ;var repo = './path/to/repo'; repo;
Or alternatively, to instantly create a repo and perform some operation:
;
Contributing
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.
Release History
- 0.2.1 - add tests to assert behaviour with associated fixups
- 0.2.0 - add a new repo() method to the API
- 0.1.2 - make sure cwd argument we pass to exec is made absolute
- 0.1.1 - cleanup the code; no functional changes
- 0.1.0 - initial release
License
Copyright (c) 2013 Alex J Burke Licensed under the MIT license.