Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE',
Not only can you can write files, you can of course read them.

```js
// Retrieve contents of a certain file (assumes UTF-8)

repo.read('master', 'path/to/file', function(err, data) {

});
Expand All @@ -43,9 +45,23 @@ repo.read('master', 'path/to/file', function(err, data) {
Listing all files of a repository is easy too.

```js
// Retrieve contents of a certain file (assumes UTF-8)

repo.list('master', 'path/to/file', function(err, data) {

});
```
```


Node.js
--------------

To use Github.js on a node.js server, include it with require():

```js
var Github = require("/path/to/github.js");

var github = new Github({
username: "YOU_USER",
password: "YOUR_PASSWORD",
auth: "basic"
});
```
20 changes: 17 additions & 3 deletions github.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// http://substance.io/michael/github

(function() {
var Github;

var API_URL = 'https://api.github.com';

Github = window.Github = function(options) {
var Github = function(options) {
var username = options.username;
var password = options.password;

Expand Down Expand Up @@ -236,4 +236,18 @@
return new Github.User();
};
};

// Export the Github object for Node.js, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `Github` as a global object via a string identifier,
// for Closure Compiler "advanced" mode.
if (typeof exports !== "undefined") {
if (typeof module !== "undefined" && module.exports) {
exports = module.exports = Github;
}
exports.Github = Github;
} else {
this['Github'] = Github;
}

}).call(this);