Skip to content

Commit c3adb2e

Browse files
committed
Fixed code style issues
1 parent af1365f commit c3adb2e

File tree

3 files changed

+87
-32
lines changed

3 files changed

+87
-32
lines changed

dist/github.bundle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/github.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.js

Lines changed: 85 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@
1414
(function (root, factory) {
1515
/* istanbul ignore next */
1616
if (typeof define === 'function' && define.amd) {
17-
define(['es6-promise', 'base-64', 'utf8', 'axios'], function (Promise, Base64, Utf8, axios) {
18-
return (root.Github = factory(Promise, Base64, Utf8, axios));
19-
});
17+
define(
18+
[
19+
'es6-promise',
20+
'base-64',
21+
'utf8',
22+
'axios'
23+
],
24+
function (Promise, Base64, Utf8, axios) {
25+
return (root.Github = factory(Promise, Base64, Utf8, axios));
26+
}
27+
);
2028
} else if (typeof module === 'object' && module.exports) {
2129
module.exports = factory(require('es6-promise'), require('base-64'), require('utf8'), require('axios'));
2230
} else {
2331
root.Github = factory(root.Promise, root.base64, root.utf8, root.axios);
2432
}
25-
}(this, function(Promise, Base64, Utf8, axios) {
33+
}(this, function(Promise, Base64, Utf8, axios) { // jshint ignore:line
2634
function b64encode(string) {
2735
return Base64.encode(Utf8.encode(string));
2836
}
@@ -49,7 +57,7 @@
4957
url += ((/\?/).test(url) ? '&' : '?');
5058

5159
if (data && typeof data === 'object' && ['GET', 'HEAD', 'DELETE'].indexOf(method) > -1) {
52-
for (var param in data) {
60+
for(var param in data) {
5361
if (data.hasOwnProperty(param)) {
5462
url += '&' + encodeURIComponent(param) + '=' + encodeURIComponent(data[param]);
5563
}
@@ -71,7 +79,7 @@
7179
};
7280

7381
if ((options.token) || (options.username && options.password)) {
74-
config.headers['Authorization'] = options.token ?
82+
config.headers.Authorization = options.token ?
7583
'token ' + options.token :
7684
'Basic ' + b64encode(options.username + ':' + options.password);
7785
}
@@ -160,7 +168,7 @@
160168

161169
url += '?' + params.join('&');
162170

163-
_requestAllPages(url, cb);
171+
_requestAllPages(url, cb);
164172
};
165173

166174
// List user organizations
@@ -450,7 +458,10 @@
450458

451459
this.listBranches = function (cb) {
452460
_request('GET', repoPath + '/git/refs/heads', null, function (err, heads, xhr) {
453-
if (err) return cb(err);
461+
if (err) {
462+
return cb(err);
463+
}
464+
454465
cb(null, heads.map(function (head) {
455466
return head.ref.replace(/^refs\/heads\//, '');
456467
}), xhr);
@@ -475,10 +486,16 @@
475486
// -------
476487

477488
this.getSha = function (branch, path, cb) {
478-
if (!path || path === '') return that.getRef('heads/' + branch, cb);
489+
if (!path || path === '') {
490+
return that.getRef('heads/' + branch, cb);
491+
}
492+
479493
_request('GET', repoPath + '/contents/' + path + (branch ? '?ref=' + branch : ''),
480494
null, function (err, pathContent, xhr) {
481-
if (err) return cb(err);
495+
if (err) {
496+
return cb(err);
497+
}
498+
482499
cb(null, pathContent.sha, xhr);
483500
});
484501
};
@@ -495,7 +512,10 @@
495512

496513
this.getTree = function (tree, cb) {
497514
_request('GET', repoPath + '/git/trees/' + tree, null, function (err, res, xhr) {
498-
if (err) return cb(err);
515+
if (err) {
516+
return cb(err);
517+
}
518+
499519
cb(null, res.tree, xhr);
500520
});
501521
};
@@ -517,7 +537,10 @@
517537
}
518538

519539
_request('POST', repoPath + '/git/blobs', content, function (err, res) {
520-
if (err) return cb(err);
540+
if (err) {
541+
return cb(err);
542+
}
543+
521544
cb(null, res.sha);
522545
});
523546
};
@@ -539,7 +562,10 @@
539562
};
540563

541564
_request('POST', repoPath + '/git/trees', data, function (err, res) {
542-
if (err) return cb(err);
565+
if (err) {
566+
return cb(err);
567+
}
568+
543569
cb(null, res.sha);
544570
});
545571
};
@@ -552,7 +578,10 @@
552578
_request('POST', repoPath + '/git/trees', {
553579
tree: tree
554580
}, function (err, res) {
555-
if (err) return cb(err);
581+
if (err) {
582+
return cb(err);
583+
}
584+
556585
cb(null, res.sha);
557586
});
558587
};
@@ -565,7 +594,10 @@
565594
var user = new Github.User();
566595

567596
user.show(null, function (err, userData) {
568-
if (err) return cb(err);
597+
if (err) {
598+
return cb(err);
599+
}
600+
569601
var data = {
570602
message: message,
571603
author: {
@@ -579,7 +611,10 @@
579611
};
580612

581613
_request('POST', repoPath + '/git/commits', data, function (err, res) {
582-
if (err) return cb(err);
614+
if (err) {
615+
return cb(err);
616+
}
617+
583618
currentTree.sha = res.sha; // Update latest commit
584619
cb(null, res.sha);
585620
});
@@ -610,7 +645,9 @@
610645
var that = this;
611646

612647
_request('GET', repoPath + '/stats/contributors', null, function (err, data, xhr) {
613-
if (err) return cb(err);
648+
if (err) {
649+
return cb(err);
650+
}
614651

615652
if (xhr.status === 202) {
616653
setTimeout(
@@ -660,7 +697,10 @@
660697
}
661698

662699
this.getRef('heads/' + oldBranch, function (err, ref) {
663-
if (err && cb) return cb(err);
700+
if (err && cb) {
701+
return cb(err);
702+
}
703+
664704
that.createRef({
665705
ref: 'refs/heads/' + newBranch,
666706
sha: ref
@@ -716,9 +756,14 @@
716756
this.read = function (branch, path, cb) {
717757
_request('GET', repoPath + '/contents/' + encodeURI(path) + (branch ? '?ref=' + branch : ''),
718758
null, function (err, obj, xhr) {
719-
if (err && err.error === 404) return cb('not found', null, null);
759+
if (err && err.error === 404) {
760+
return cb('not found', null, null);
761+
}
762+
763+
if (err) {
764+
return cb(err);
765+
}
720766

721-
if (err) return cb(err);
722767
cb(null, obj, xhr);
723768
}, true);
724769
};
@@ -728,7 +773,10 @@
728773

729774
this.remove = function (branch, path, cb) {
730775
that.getSha(branch, path, function (err, sha) {
731-
if (err) return cb(err);
776+
if (err) {
777+
return cb(err);
778+
}
779+
732780
_request('DELETE', repoPath + '/contents/' + path, {
733781
message: path + ' is removed',
734782
sha: sha,
@@ -749,9 +797,13 @@
749797
that.getTree(latestCommit + '?recursive=true', function (err, tree) {
750798
// Update Tree
751799
tree.forEach(function (ref) {
752-
if (ref.path === path) ref.path = newPath;
800+
if (ref.path === path) {
801+
ref.path = newPath;
802+
}
753803

754-
if (ref.type === 'tree') delete ref.sha;
804+
if (ref.type === 'tree') {
805+
delete ref.sha;
806+
}
755807
});
756808

757809
that.postTree(tree, function (err, rootTree) {
@@ -782,7 +834,10 @@
782834
};
783835

784836
// If no error, we set the sha to overwrite an existing file
785-
if (!(err && err.error !== 404)) writeOptions.sha = sha;
837+
if (!(err && err.error !== 404)) {
838+
writeOptions.sha = sha;
839+
}
840+
786841
_request('PUT', repoPath + '/contents/' + encodeURI(path), writeOptions, cb);
787842
});
788843
};
@@ -858,14 +913,14 @@
858913
// --------
859914

860915
this.star = function(owner, repository, cb) {
861-
_request('PUT', '/user/starred/' + owner + '/' + repository, null, cb)
916+
_request('PUT', '/user/starred/' + owner + '/' + repository, null, cb);
862917
};
863918

864919
// Unstar a repository.
865920
// --------
866921

867922
this.unstar = function(owner, repository, cb) {
868-
_request('DELETE', '/user/starred/' + owner + '/' + repository, null, cb)
923+
_request('DELETE', '/user/starred/' + owner + '/' + repository, null, cb);
869924
};
870925
};
871926

@@ -951,7 +1006,7 @@
9511006
this.list = function (options, cb) {
9521007
var query = [];
9531008

954-
for (var key in options) {
1009+
for(var key in options) {
9551010
if (options.hasOwnProperty(key)) {
9561011
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(options[key]));
9571012
}
@@ -998,13 +1053,13 @@
9981053
this.getRateLimit = function(cb) {
9991054
_request('GET', '/rate_limit', null, cb);
10001055
};
1001-
}
1056+
};
10021057

10031058
return Github;
10041059
};
10051060

1006-
// Top Level API
1007-
// -------
1061+
// Top Level API
1062+
// -------
10081063

10091064
Github.getIssues = function (user, repo) {
10101065
return new Github.Issue({

0 commit comments

Comments
 (0)