Skip to content

Commit

Permalink
Add a check for the fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Oct 23, 2017
1 parent d063ef0 commit c2756fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 9 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ const missing = names.filter(n => !readme.includes(n))
if (missing.length) {
warn(`These providers are missing from the README: ${sentence(missing)}`)
}

console.log("before")
danger.github.utils.fileContents("scripts/run-fixtures.js").then(fixtures => {
console.log("after")
console.log(fixtures)
if (fixtures.includes("const writeResults = true")) {
fail("Fixtures test script is still in write mode, edit `scripts/run-fixtures.js`.")
}
})
2 changes: 1 addition & 1 deletion scripts/run-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const expect = require("expect")

// Toggle this on to update the JSON files for each run
const writeResults = true

console.log("If this script fails, you probably want to update the fixtures - just edit script/run-fixtures.js")
const runnerFileJS = "distribution/commands/danger-runner.js"

// Get all the fixtures
Expand Down
11 changes: 5 additions & 6 deletions source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ const utils = (pr: GitHubPRDSL, api: GitHub): GitHubUtilsDSL => {
repoSlug = pr.head.repo.full_name
ref = pr.head.ref
}

const data = await api.repos.getContent({
const opts = {
ref,
path,
repo: repoSlug.split("/")[1],
owner: repoSlug.split("/")[0],
})

if (data && data.type === "file") {
const buffer = new Buffer(data.content, data.encoding)
}
const response = await api.repos.getContent(opts)
if (response && response.data && response.data.type === "file") {
const buffer = new Buffer(response.data.content, "base64")
return buffer.toString()
} else {
return ""
Expand Down

0 comments on commit c2756fd

Please sign in to comment.