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 f414462
Show file tree
Hide file tree
Showing 3 changed files with 23 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
19 changes: 13 additions & 6 deletions source/platforms/github/GitHubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,25 @@ 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],
})

}
const response = await api.repos.getContent(opts)
const data = response.data
console.log("keys:", Object.keys(data))
if (data && data.type === "file") {
const buffer = new Buffer(data.content, data.encoding)
return buffer.toString()
console.log("found:", data.name)
const buffer = new Buffer(data.content, "base64")
console.log("content:", data.content)
const content = buffer.toString()
console.log("content: ", content)
return content
} else {
console.log("no data or wrong type")
console.log("type:", data && data.type)
return ""
}
},
Expand Down

0 comments on commit f414462

Please sign in to comment.