From b62c3b13f5c3ebc72e218a9d5f5e146ffa371aca Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Fri, 12 Jun 2020 09:16:31 +0200 Subject: [PATCH] refactor: move user agent insertion into util/got --- lib/util/got/index.ts | 3 +-- lib/util/got/renovate-agent.ts | 11 ----------- lib/util/http/index.ts | 4 ++++ 3 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 lib/util/got/renovate-agent.ts diff --git a/lib/util/got/index.ts b/lib/util/got/index.ts index 0a058615dbc425..158aee09a61cd4 100644 --- a/lib/util/got/index.ts +++ b/lib/util/got/index.ts @@ -1,7 +1,6 @@ import auth from './auth'; import cacheGet from './cache-get'; import hostRules from './host-rules'; -import renovateAgent from './renovate-agent'; import { mergeInstances } from './util'; export * from './common'; @@ -12,6 +11,6 @@ export * from './common'; * - Cache all GET requests for the lifetime of the repo * */ -export const api = mergeInstances(cacheGet, renovateAgent, hostRules, auth); +export const api = mergeInstances(cacheGet, hostRules, auth); export default api; diff --git a/lib/util/got/renovate-agent.ts b/lib/util/got/renovate-agent.ts deleted file mode 100644 index 5b2eea2bfc1c85..00000000000000 --- a/lib/util/got/renovate-agent.ts +++ /dev/null @@ -1,11 +0,0 @@ -import got from 'got'; - -// Sets the user agent to be Renovate - -export default got.extend({ - headers: { - 'user-agent': - process.env.RENOVATE_USER_AGENT || - 'https://github.com/renovatebot/renovate', - }, -}); diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts index 01a1a0899279ef..8adb7df1f01fe9 100644 --- a/lib/util/http/index.ts +++ b/lib/util/http/index.ts @@ -67,6 +67,10 @@ export class Http { }, ], }; + combinedOptions.headers = combinedOptions.headers || {}; + combinedOptions.headers['user-agent'] = + process.env.RENOVATE_USER_AGENT || + 'https://github.com/renovatebot/renovate'; const res = await got(resolvedUrl, combinedOptions); return { body: res.body, headers: res.headers }; }