git-object
Advanced tools
Comparing version 0.0.1 to 0.0.2
0.0.2 / 2013-07-30 | ||
================== | ||
* Updated documentation | ||
0.0.1 / 2013-07-30 | ||
@@ -3,0 +8,0 @@ ================== |
{ | ||
"name": "git-object", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple library to retrieve git objects from a repository.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,4 +6,63 @@ | ||
## License | ||
## Usage | ||
To retrieve a blob from a git repository use the following: | ||
```js | ||
var git = require('git-object'); | ||
// retrieve a blob | ||
git('.', 'master', 'index.js', function(err, object){ | ||
if (err) return console.log(err); // fail | ||
if (object instanceof git.Blob) { | ||
// create read stream an use it | ||
object.createReadStream().pipe(process.stdout); | ||
} else { | ||
console.log('not a blob'); | ||
} | ||
}); | ||
``` | ||
Reading of a tree is just as simple as this: | ||
```js | ||
// retrieve a tree | ||
git('.', 'master', 'lib/', function(err, object){ | ||
if (err) return console.log(err); // fail | ||
if (object instanceof git.Tree) { | ||
object.contents(function(err, contents){ | ||
if (err) return done(err); | ||
contents.should.eql([ | ||
'git-object.js' | ||
]); | ||
done(); | ||
}); | ||
} else { | ||
console.log('not a tree'); | ||
} | ||
}); | ||
``` | ||
## API | ||
### Blob | ||
This is the class which is generated by reading a blob. | ||
#### .createReadStream() | ||
Create a stream to the object. This stream is then returned. | ||
### Tree | ||
#### .contents() | ||
Returns the filenames of the tree as array. | ||
## License | ||
(The MIT License) | ||
@@ -30,2 +89,2 @@ | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
6686
8
89