diff --git a/README.md b/README.md index 31f043e..f09862e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ publisher.publish('_post/2015-07-17-example-post.md', 'file content').then(funct * **force** – whether to replace any pre-existing file no matter what * **message** – a custom commit message. Default is `new content` * **sha** – the sha of an existing file that one wants to replace +* **author** – `{name, email}` of the commit author ## License diff --git a/index.js b/index.js index 3cb380e..8cac779 100644 --- a/index.js +++ b/index.js @@ -90,6 +90,10 @@ GitHubPublisher.prototype.publish = function (file, content, options) { const data = { message: options.message || 'new content', + author: options.author ? { + name: options.author.name, + email: options.author.email + } : {}, content: this.base64(content) }; diff --git a/test/github.spec.js b/test/github.spec.js index ad88ff4..efa9290 100644 --- a/test/github.spec.js +++ b/test/github.spec.js @@ -201,5 +201,31 @@ describe('GitHubPublisher', () => { result.should.equal(createdSha); }); }); + + it('should allow customizeable commit authors', () => { + publisher = new GitHubPublisher(token, user, repo); + + const mock = nock('https://api.github.com/') + .put(path, { + message: 'foobar2', + content: base64, + author: { + name: 'Clint', + email: 'clint@someone.com' + } + }) + .reply(201, githubCreationResponse); + + return publisher.publish(file, content, { + message: 'foobar2', + author: { + name: 'Clint', + email: 'clint@someone.com' + } + }).then(result => { + mock.done(); + result.should.equal(createdSha); + }); + }); }); });