From 1b38827df02a00c60751eb33451c53421b1f510b Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Tue, 20 Nov 2018 10:23:17 -0500 Subject: [PATCH] Make a fix for local process checking for platforms --- CHANGELOG.md | 6 +++--- source/ci_source/providers/Fake.ts | 1 + source/ci_source/providers/index.ts | 2 +- source/platforms/platform.ts | 6 ++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1abccf927..891f7718b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,9 +16,9 @@ - Adds `html_url` to the PR JSON declaration - [@orta][] - Adds a way for a sub-process to tell danger-js that it wants a copy of the DSL. This is a potential fix for when you have a process that might not be ready to grab the DSL instantly from danger-js. The subprocess can print the message - `danger://send-dsl` to stdout and danger-js will re-send the DSL via STDIN. - [@orta][] - -These two are to try and figure out [danger/swift#108](https://github.com/danger/swift/issues/108). + `danger://send-dsl` to stdout and danger-js will re-send the DSL via STDIN. + [danger/swift#108](https://github.com/danger/swift/issues/108). - [@orta][] +- Allows a FakeCI to get a FakePlatform, should fix [#767](https://github.com/danger/danger-js/issues/767) - [@orta][] # 6.1.4 diff --git a/source/ci_source/providers/Fake.ts b/source/ci_source/providers/Fake.ts index e62006e0e..d491c2796 100644 --- a/source/ci_source/providers/Fake.ts +++ b/source/ci_source/providers/Fake.ts @@ -19,6 +19,7 @@ export class FakeCI implements CISource { get isCI(): boolean { return ensureEnvKeysExist(this.env, ["DANGER_FAKE_CI"]) || ensureEnvKeysExist(this.env, ["DANGER_LOCAL_NO_CI"]) } + get isPR(): boolean { return true } diff --git a/source/ci_source/providers/index.ts b/source/ci_source/providers/index.ts index 186fd22eb..71d7df917 100644 --- a/source/ci_source/providers/index.ts +++ b/source/ci_source/providers/index.ts @@ -19,13 +19,13 @@ import { Travis } from "./Travis" import { VSTS } from "./VSTS" const providers = [ + FakeCI, GitHubActions, Travis, Circle, Semaphore, Nevercode, Jenkins, - FakeCI, Surf, DockerCloud, Codeship, diff --git a/source/platforms/platform.ts b/source/platforms/platform.ts index b1a37eb87..d92c7ee01 100644 --- a/source/platforms/platform.ts +++ b/source/platforms/platform.ts @@ -8,6 +8,7 @@ import { DangerResults } from "../dsl/DangerResults" import { ExecutorOptions } from "../runner/Executor" import { DangerRunner } from "../runner/runners/runner" import chalk from "chalk" +import { FakePlatform } from "./FakePlatform" /** A type that represents the downloaded metadata about a code review session */ export type Metadata = any @@ -87,6 +88,11 @@ export interface PlatformCommunicator { * @returns {Platform} returns a platform if it can be supported */ export function getPlatformForEnv(env: Env, source: CISource, requireAuth = true): Platform { + // Support automatically returning a fake platform if you pass a Fake CI + if (source.name === "Fake Testing CI") { + return new FakePlatform() + } + // BitBucket Server const bbsHost = env["DANGER_BITBUCKETSERVER_HOST"] if (bbsHost) {