Skip to content

Commit

Permalink
Moves DangerfileRunner to use async methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashfurrow committed Oct 1, 2017
1 parent 4b498f0 commit 2f59cf3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions source/runner/DangerfileRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,25 @@ export async function runDangerfileEnvironment(
): Promise<DangerResults> {
const vm = new NodeVM(environment)

const fetchContents = async () => {
return new Promise<string>((resolve, reject) => {
if (originalContents) {
resolve(originalContents)
} else {
fs.readFile(filename, "utf8", (error, data) => {
if (error) {
reject(error)
} else {
resolve(data)
}
})
}
})
}

// Require our dangerfile
originalContents = originalContents || fs.readFileSync(filename, "utf8")
let content = cleanDangerfile(originalContents)
const fetchedContents = await fetchContents()
let content = cleanDangerfile(fetchedContents)

// TODO: Relative imports get TS/Babel

Expand Down

0 comments on commit 2f59cf3

Please sign in to comment.