Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const path of input.paths) {
const rep = dangerRepresentationForPath(path)
const defaultRepoSlug = payload.dsl.github.pr.base.repo.full_name
const dangerfileContent = await getGitHubFileContentsFromLocation(token, rep, defaultRepoSlug)
contents.push(dangerfileContent)
}
// Because it's not feasible to get stderr from hyper
process.stderr.write = process.stdout.write
// Run it
runtimeEnv = await inlineRunner.createDangerfileRuntimeEnvironment(context)
// Use custom module resolution inside the danger env
const restoreOriginalModuleLoader = overrideRequire(shouldUseGitHubOverride, customGitHubResolveRequest(token))
const results = await inlineRunner.runDangerfileEnvironment(paths, contents, runtimeEnv)
restoreOriginalModuleLoader()
// Give a small summary
logger.info(
`f: ${results.fails.length} w: ${results.warnings.length} m: ${results.messages.length} md: ${
results.markdowns.length
}`
)
// Wait till the end of the process to print out the results. Will
// only post the results when the process has succeeded, leaving the
// host process to create a message from the logs.
exitHook((callback: () => void) => {
const endTime = new Date().getTime()
const duration = (startTime - endTime) / 1000
logger.info(`Danger run finished in ${duration}, sending results`)
logger.info(`Process finished, sending results`)
postResultsCall(
input.perilSettings.perilAPIRoot,
input.perilSettings.perilJWT,
input.perilSettings.event,
input.paths,
1234,
process.env.HYPER_CALL_ID || ""
).then(callback)
})
runtimeEnv = await inlineRunner.createDangerfileRuntimeEnvironment(context)
// Use custom module resolution inside the danger env
const restoreOriginalModuleLoader = overrideRequire(shouldUseGitHubOverride, customGitHubResolveRequest(token))
await inlineRunner.runDangerfileEnvironment(paths, contents, runtimeEnv, payload.webhook)
// Restore the original module loader.
restoreOriginalModuleLoader()
}