Skip to content

Commit

Permalink
Minor changes to readme and github output + fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Gaunt committed Aug 4, 2017
1 parent a12279e commit eb8d9de
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
node_modules
coverage
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -37,12 +37,12 @@ to your Github repository).
1. In this new file add the following:

```javascript
const travisbot = require('pr-bot');
const prbot = require('pr-bot');

module.exports = {
botUsername: `<Add the Github Username for your Bot Account Here>`
plugins: [
new travisbot.plugins.Size({
new prbot.plugins.Size({
globPattern: '**/*.js',
globOptions: {
ignore: [
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "pr-bot",
"version": "0.0.18",
"version": "0.0.1",
"description": "A bot to run after Travis has run it's build's and tests.",
"main": "src/npm-module.js",
"bin": {
Expand All @@ -14,7 +14,7 @@
"type": "git",
"url": "git+https://github.com/gauntface/web-devrel-bot.git"
},
"author": "gauntface",
"author": "Google Web DevRel",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/gauntface/web-devrel-bot/issues"
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/bot-runner.js
Expand Up @@ -24,7 +24,7 @@ const TMPDIR_PREFIX = `/tmp/pr-bot/`;

class TravisBot {
constructor({configPath} = {}) {
logHelper.setPrimaryPrefix('TravisBot 馃');
logHelper.setPrimaryPrefix('PR-Bot 馃');

if (!configPath) {
configPath = path.resolve('pr-bot.config.js')
Expand Down Expand Up @@ -178,11 +178,11 @@ class TravisBot {
}

_logGithubState(configuration, travisEnv, githubController, pluginResults) {
let githubComment = `# Results from Plugins\n\n`;
let githubComment = ``;
const pluginNames = Object.keys(pluginResults);
pluginNames.forEach((pluginName) => {
const result = pluginResults[pluginName];
githubComment += `## ${pluginName}\n\n`;
githubComment += `### ${pluginName}\n\n`;
if (result.markdownLog) {
githubComment += result.markdownLog;
} else {
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/size.js
Expand Up @@ -252,16 +252,18 @@ class SizePlugin extends PluginInterface {
newTable = 'No new files have been added.';
}

return `## Changed File Sizes
return `#### Changed File Sizes
${changedTable}
## New Files
#### New Files
${newTable}
#### All File Sizes
<details>
<summary>All Files</summary>
<summary>View Table</summary>
${fullTable}
Expand Down
16 changes: 10 additions & 6 deletions test/node/plugins/test-size.js
Expand Up @@ -85,7 +85,7 @@ new-file.txt 21 B

console.log(results.markdownLog);

expect(results.markdownLog).to.equal(`## Changed File Sizes
expect(results.markdownLog).to.equal(`#### Changed File Sizes
| File | Before | After | Change | |
| --- | --- | --- | --- | --- |
Expand All @@ -95,14 +95,16 @@ new-file.txt 21 B
| minor-change.txt | 7.126 KB | 7.125 KB | -0.01% | |
| stays-the-same.txt | 29 B | 50 B | +72.41% | 鈽狅笍 |
## New Files
#### New Files
| File | Size |
| --- | --- |
| new-file.txt | 21 B |
#### All File Sizes
<details>
<summary>All Files</summary>
<summary>View Table</summary>
| File | Before | After | Change | |
| --- | --- | --- | --- | --- |
Expand Down Expand Up @@ -146,16 +148,18 @@ No new files have been added.

console.log(results.markdownLog);

expect(results.markdownLog).to.equal(`## Changed File Sizes
expect(results.markdownLog).to.equal(`#### Changed File Sizes
No file sizes have changed.
## New Files
#### New Files
No new files have been added.
#### All File Sizes
<details>
<summary>All Files</summary>
<summary>View Table</summary>
| File | Before | After | Change | |
| --- | --- | --- | --- | --- |
Expand Down
4 changes: 2 additions & 2 deletions test/node/test-travis-bot.js
Expand Up @@ -147,7 +147,7 @@ describe('bot-runner', function() {
const issueStub = sinon.stub(FakeGithubController.prototype, 'postIssueComment').callsFake((input) => {
expect(input).to.deep.equal({
number: '123',
comment: '# Results from Plugins\n\n## Good Plugin.\n\nThis plugin provided no markdown output.\n\n## Good Plugin 2.\n\n`Hello from good plugin.`\n\n'
comment: '### Good Plugin.\n\nThis plugin provided no markdown output.\n\n### Good Plugin 2.\n\n`Hello from good plugin.`\n\n',
});
return Promise.resolve();
});
Expand All @@ -168,7 +168,7 @@ describe('bot-runner', function() {
const issueStub = sinon.stub(FakeGithubController.prototype, 'postIssueComment').callsFake((input) => {
expect(input).to.deep.equal({
number: '123',
comment: '# Results from Plugins\n\n## Good Plugin.\n\nThis plugin provided no markdown output.\n\n## Good Plugin 2.\n\n`Hello from good plugin.`\n\n'
comment: '### Good Plugin.\n\nThis plugin provided no markdown output.\n\n### Good Plugin 2.\n\n`Hello from good plugin.`\n\n'
});
return Promise.resolve();
});
Expand Down

0 comments on commit eb8d9de

Please sign in to comment.