Skip to content

Commit

Permalink
feat(getCISourceForEnv): dynamically detect available ci source
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Dec 31, 2016
1 parent 79416ca commit 193a2d4
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions source/ci_source/ci_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export interface CISource {
+pullRequestID: string,
}

import Travis from "./Travis"
import Circle from "./Circle"
import Semaphore from "./Semaphore"
import Jenkins from "./Jenkins"
import Fake from "./Fake"
import providers from "./providers"

/**
* Gets a CI Source form the current environment, by asking all known
Expand All @@ -41,21 +37,7 @@ import Fake from "./Fake"
* @returns {?CISource} a CI source if it's OK, otherwise Danger can't run.
*/
export function getCISourceForEnv(env: Env): ?CISource {
const travis = new Travis(env)
const circle = new Circle(env)
const semaphore = new Semaphore(env)
const jenkins = new Jenkins(env)
const fake = new Fake(env)

if (travis.isCI) {
return travis
} else if (circle.isCI) {
return circle
} else if (semaphore.isCI) {
return semaphore
} else if (jenkins.isCI) {
return jenkins
} else if (fake.isCI) {
return fake
}
const availableProviders = [...providers].map(Provider => new Provider(env)).filter(x => x.isCI)
return (availableProviders && availableProviders.length > 0) ? availableProviders[0] : undefined
}

0 comments on commit 193a2d4

Please sign in to comment.