Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};

Expand Down
26 changes: 26 additions & 0 deletions test/github.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'
}
})
.reply(201, githubCreationResponse);

return publisher.publish(file, content, {
message: 'foobar2',
author: {
name: 'Clint',
email: '[email protected]'
}
}).then(result => {
mock.done();
result.should.equal(createdSha);
});
});
});
});