UNPKG

@rajzik/lumos

Version:

Centralized CLI for JavaScript and TypeScript dev tools.

25 lines (24 loc) 917 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createGitHubClient = void 0; const rest_1 = require("@octokit/rest"); const constants_1 = require("../constants"); function createGitHubClient(token) { const { GITHUB_TOKEN, GHE_API_URL, GHE_VERSION } = process.env; const options = { userAgent: `Lumos v${constants_1.VERSION}`, }; if (token !== null && token !== void 0 ? token : GITHUB_TOKEN) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing options.auth = `token ${token || GITHUB_TOKEN}`; } if (GHE_API_URL) { options.baseUrl = GHE_API_URL; } if (GHE_VERSION) { // eslint-disable-next-line rest_1.Octokit.plugin(require(`@octokit/plugin-enterprise-rest/ghe-${GHE_VERSION}`)); } return new rest_1.Octokit(options); } exports.createGitHubClient = createGitHubClient;