From bbc3e48205d2cd1c3d2ccbca680482d5aaf9976d Mon Sep 17 00:00:00 2001 From: Gregor Martynus Date: Sun, 2 Feb 2020 16:47:59 -0800 Subject: [PATCH] feat: deprecate `const Octokit = require("@octokit/rest")` in favor of `const { Octokit } = require("@octokit/rest")` --- index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 29112b46..ab06bc83 100644 --- a/index.js +++ b/index.js @@ -16,4 +16,17 @@ const CORE_PLUGINS = [ require("octokit-pagination-methods") // deprecated: remove in v17 ]; -module.exports = Octokit.plugin(CORE_PLUGINS); +const OctokitRest = Octokit.plugin(CORE_PLUGINS); + +function DeprecatedOctokit(options) { + const warn = + options.log && options.log.warn ? options.log.warn : console.warn; + warn( + '[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead' + ); + return new OctokitRest(options); +} + +module.exports = Object.assign(DeprecatedOctokit, { + Octokit: OctokitRest +});