Skip to content

Commit eb2b4f3

Browse files
committed
fix(repository): prevents lib from crashing when not providing optional arguments
1 parent 29c3c7a commit eb2b4f3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/Repository.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ class Repository extends Requestable {
749749
* @return {Promise} - the promise for the http request
750750
*/
751751
writeFile(branch, path, content, message, options, cb) {
752+
options = options || {};
752753
if (typeof options === 'function') {
753754
cb = options;
754755
options = {};

test/repository.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,17 @@ describe('Repository', function() {
385385
}));
386386
});
387387

388+
it('should successfully write to repo when not providing optional options argument', function(done) {
389+
remoteRepo.writeFile('master', fileName, initialText, initialMessage, undefined, assertSuccessful(done, function() {
390+
wait()().then(() => remoteRepo.getContents('master', fileName, 'raw',
391+
assertSuccessful(done, function(err, fileText) {
392+
expect(fileText).to.be(initialText);
393+
394+
done();
395+
})));
396+
}));
397+
});
398+
388399
it('should rename files', function(done) {
389400
remoteRepo.writeFile('master', fileName, initialText, initialMessage, assertSuccessful(done, function() {
390401
wait()().then(() => remoteRepo.move('master', fileName, 'new_name', assertSuccessful(done, function() {

0 commit comments

Comments
 (0)