Skip to content

Commit

Permalink
feat(danger): support custom dangerfile name
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Jan 14, 2017
1 parent 5ddce59 commit f750656
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### master

// Add your own contribution below
* Support custom dangerfile via `-d` commandline arg - kwonoj
* Allow debug dump output via `DEBUG=danger:*` environment variable - kwonoj
* Adds surf-build ci provider - kwonoj
* Forward environment variable to external module constructor - kwonoj
Expand Down
21 changes: 18 additions & 3 deletions source/commands/danger-run.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import * as program from "commander"
import * as debug from "debug"
import * as fs from "fs"
import { getCISource } from "../ci_source/get_ci_source"
import { getPlatformForEnv } from "../platforms/platform"
import {Executor} from "../runner/Executor"

const d = debug("danger:run")
declare const global: any

program
.option("-v, --verbose", "Verbose output of files")
.option("-c, --external-ci-provider [modulePath]", "blah")
.option("-c, --external-ci-provider [modulePath]", "Specify custom CI provider")
.option("-d, --dangerfile [filePath]", "Specify custom dangefile other than default dangerfile.js")
.parse(process.argv)

process.on("unhandledRejection", function(reason: string, _p: any) {
Expand Down Expand Up @@ -39,10 +43,21 @@ if (source && source.isPR) {
}

if (platform) {
const dangerFile = (program as any).dangerfile || "dangerfile.js"

console.log(`OK, looks good ${source.name} on ${platform.name}`)

try {
const exec = new Executor(source, platform)
exec.setupAndRunDanger("dangerfile.js")
const stat = fs.statSync(dangerFile)

if (!!stat && stat.isFile()) {
d(`executing dangerfile at ${dangerFile}`)
const exec = new Executor(source, platform)
exec.setupAndRunDanger(dangerFile)
} else {
console.log(`looks like specified ${dangerFile} is not valid path`)
process.exitCode = 1
}
} catch (error) {
process.exitCode = 1
console.error(error.message)
Expand Down

0 comments on commit f750656

Please sign in to comment.