Skip to content

Commit 126301b

Browse files
committed
Update github.js
1 parent 5e8ac76 commit 126301b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

github.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
if (this.status >= 200 && this.status < 300 || this.status === 304) {
2323
cb(null, raw ? this.responseText : this.responseText ? JSON.parse(this.responseText) : true);
2424
} else {
25-
cb(this.status);
25+
cb({request: this, error: this.status});
2626
}
2727
}
2828
}
2929
xhr.setRequestHeader('Accept','application/vnd.github.raw');
30-
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
30+
xhr.setRequestHeader('Content-Type','application/json');
3131
if (
3232
(options.auth == 'oauth' && options.token) ||
3333
(options.auth == 'basic' && options.username && options.password)
@@ -335,9 +335,13 @@
335335

336336
this.write = function(branch, path, content, message, cb) {
337337
updateTree(branch, function(err, latestCommit) {
338+
if (err) return cb(err);
338339
that.postBlob(content, function(err, blob) {
340+
if (err) return cb(err);
339341
that.updateTree(latestCommit, path, blob, function(err, tree) {
342+
if (err) return cb(err);
340343
that.commit(latestCommit, tree, message, function(err, commit) {
344+
if (err) return cb(err);
341345
that.updateHead(branch, commit, cb);
342346
});
343347
});

0 commit comments

Comments
 (0)