Skip to content

Commit

Permalink
When you have empty results, return empty results so that danger dele…
Browse files Browse the repository at this point in the history
…tes the comment
  • Loading branch information
orta committed Jul 21, 2018
1 parent c71c297 commit e1ee7ca
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions source/platforms/github/comms/checksCommenter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GitHubAPI } from "../GitHubAPI"
import { DangerResults } from "../../../dsl/DangerResults"
import { DangerResults, isEmptyResults, emptyResults } from "../../../dsl/DangerResults"
import { ExecutorOptions } from "../../../runner/Executor"
import { resultsToCheck } from "./checks/resultsToCheck"
import { getAccessTokenForInstallation } from "./checks/githubAppSupport"
Expand Down Expand Up @@ -92,19 +92,22 @@ export const GitHubChecksCommenter = (api: GitHubAPI) => {
}
}

export const tweetSizedResultsFromResults = (results: DangerResults, checksResponse: any): DangerResults => ({
warnings: [],
messages: [],
fails: [],
markdowns: [
{
message:
"Danger run resulted in " +
messageFromResults(results) +
`; to find out more, see the [checks page](${checksResponse.html_url}).`,
},
],
})
export const tweetSizedResultsFromResults = (results: DangerResults, checksResponse: any): DangerResults =>
isEmptyResults(results)
? emptyResults()
: {
warnings: [],
messages: [],
fails: [],
markdowns: [
{
message:
"Danger run resulted in " +
messageFromResults(results) +
`; to find out more, see the [checks page](${checksResponse.html_url}).`,
},
],
}

const messageFromResults = (results: DangerResults): string => {
const appendS = (arr: any[]) => (arr.length === 1 ? "" : "s")
Expand Down

0 comments on commit e1ee7ca

Please sign in to comment.