Skip to content

Commit

Permalink
Merge pull request #480 from danger/fb/update_nevercode
Browse files Browse the repository at this point in the history
Nevercode Updated Env Vars
  • Loading branch information
orta committed Jan 16, 2018
2 parents 35fecbc + dc979bd commit b0d7e2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 10 additions & 13 deletions source/ci_source/providers/Nevercode.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import { Env, CISource } from "../ci_source"
import { ensureEnvKeysExist, ensureEnvKeysAreInt, getPullRequestIDForBranch } from "../ci_source_helpers"
import { getRepoSlug } from "../../commands/init/get-repo-slug"
import { ensureEnvKeysExist, ensureEnvKeysAreInt } from "../ci_source_helpers"

/**
* Nevercode.io CI Integration
*
* Environment Variables Documented: https://developer.nevercode.io/v1.0/docs/environment-variables-files
*/
export class Nevercode implements CISource {
private default = { prID: "0" }
constructor(private readonly env: Env) {}

async setup(): Promise<any> {
const prID = await getPullRequestIDForBranch(this, this.env, this.branchName)
this.default.prID = prID.toString()
}

get name(): string {
return "Nevercode"
}
Expand All @@ -25,17 +18,21 @@ export class Nevercode implements CISource {
}

get isPR(): boolean {
const mustHave = ["NEVERCODE_PULL_REQUEST"]
const mustBeInts = ["NEVERCODE_GIT_PROVIDER_PULL_REQUEST"]
return ensureEnvKeysExist(this.env, mustHave) && ensureEnvKeysAreInt(this.env, mustBeInts)
const mustHave = ["NEVERCODE_PULL_REQUEST", "NEVERCODE_REPO_SLUG"]
const mustBeInts = ["NEVERCODE_GIT_PROVIDER_PULL_REQUEST", "NEVERCODE_PULL_REQUEST_NUMBER"]
return (
ensureEnvKeysExist(this.env, mustHave) &&
ensureEnvKeysAreInt(this.env, mustBeInts) &&
this.env.NEVERCODE_PULL_REQUEST == "true"
)
}

get pullRequestID(): string {
return this.default.prID
return this.env.NEVERCODE_PULL_REQUEST_NUMBER
}

get repoSlug(): string {
return getRepoSlug()
return this.env.NEVERCODE_REPO_SLUG
}

get supportedPlatforms(): string[] {
Expand Down
2 changes: 2 additions & 0 deletions source/ci_source/providers/_tests/_nevercode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { getCISourceForEnv } from "../../get_ci_source"

const correctEnv = {
NEVERCODE: "true",
NEVERCODE_REPO_SLUG: "danger/danger-js",
NEVERCODE_PULL_REQUEST: "true",
NEVERCODE_PULL_REQUEST_NUMBER: "2",
NEVERCODE_GIT_PROVIDER_PULL_REQUEST: "123234",
}

Expand Down

0 comments on commit b0d7e2a

Please sign in to comment.