From a5ec5657d1bd8549601255040e4a12cbfdc35078 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 9 Oct 2019 09:51:52 -0700 Subject: [PATCH] backport dev-utils constants --- packages/kbn-dev-utils/src/constants.ts | 22 +++++++++++++++++++ packages/kbn-dev-utils/src/index.ts | 1 + .../src/failed_tests_reporter/github_api.ts | 4 ++-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 packages/kbn-dev-utils/src/constants.ts diff --git a/packages/kbn-dev-utils/src/constants.ts b/packages/kbn-dev-utils/src/constants.ts new file mode 100644 index 00000000000000..5d3b57509715e7 --- /dev/null +++ b/packages/kbn-dev-utils/src/constants.ts @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { dirname } from 'path'; + +export const REPO_ROOT = dirname(require.resolve('../../../package.json')); diff --git a/packages/kbn-dev-utils/src/index.ts b/packages/kbn-dev-utils/src/index.ts index 43dc0237604e38..1b33caea96f482 100644 --- a/packages/kbn-dev-utils/src/index.ts +++ b/packages/kbn-dev-utils/src/index.ts @@ -26,4 +26,5 @@ export { } from './tooling_log'; export { createAbsolutePathSerializer } from './serializers'; export { run, createFailError, createFlagError, combineErrors, isFailError } from './run'; +export { REPO_ROOT } from './constants'; export * from './axios'; diff --git a/packages/kbn-test/src/failed_tests_reporter/github_api.ts b/packages/kbn-test/src/failed_tests_reporter/github_api.ts index 4f8b339072ef4c..765e3d346aa50f 100644 --- a/packages/kbn-test/src/failed_tests_reporter/github_api.ts +++ b/packages/kbn-test/src/failed_tests_reporter/github_api.ts @@ -97,7 +97,7 @@ export class GithubApi { await this.request( { method: 'PATCH', - url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(issueNumber)}`), + url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(String(issueNumber))}`), data: { state: 'open', // Reopen issue if it was closed. body: newBody, @@ -111,7 +111,7 @@ export class GithubApi { await this.request( { method: 'POST', - url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(issueNumber)}/comments`), + url: Url.resolve(BASE_URL, `issues/${encodeURIComponent(String(issueNumber))}/comments`), data: { body: commentBody, },