Skip to content

Commit 5af1e07

Browse files
authored
Merge pull request #588 from hazmah0/fix-repo-write-file
fix(repository): prevents lib from crashing when not providing option…
2 parents d89a0b0 + 0234b39 commit 5af1e07

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,16 @@ describe('Repository', function() {
385385
}));
386386
});
387387

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy