UNPKG

@codechecks/client

Version:

Open source platform for code review automation

50 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const errors_1 = require("../utils/errors"); class Travis { constructor(env) { this.env = env; } isCurrentlyRunning() { return this.env["TRAVIS"] === "true"; } getPullRequestID() { const prNumberRaw = this.env["TRAVIS_PULL_REQUEST"] || "false"; if (prNumberRaw === "false") { return undefined; } return parseInt(prNumberRaw); } getCurrentSha() { let sha; if (this.env["TRAVIS_PULL_REQUEST_SHA"]) { sha = this.env["TRAVIS_PULL_REQUEST_SHA"]; } else { sha = this.env["TRAVIS_COMMIT"]; } if (!sha) { throw errors_1.crash("Couldnt get target SHA"); } return sha; } isFork() { if (this.env["TRAVIS_PULL_REQUEST"] === "false") { return false; } return !(this.env["TRAVIS_REPO_SLUG"] === this.env["TRAVIS_PULL_REQUEST_SLUG"]); } getProjectSlug() { const slug = this.env["TRAVIS_REPO_SLUG"]; if (!slug) { throw errors_1.crash("Missing TRAVIS_REPO_SLUG"); } return slug; } // we don't need to attempt to guess the PR base branch because travis always triggers /pr builds when PR (or fork) is created supportsSpeculativeBranchSelection() { return false; } } exports.Travis = Travis; //# sourceMappingURL=Travis.js.map