From a69f7b826c468956795068cb655455533e5b7599 Mon Sep 17 00:00:00 2001 From: Tony133 Date: Fri, 30 Sep 2022 15:32:42 +0200 Subject: [PATCH 1/3] chore(): remove method isobject --- lib/compiler/plugins-loader.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/compiler/plugins-loader.ts b/lib/compiler/plugins-loader.ts index 07f82feb7..1dd2226d7 100644 --- a/lib/compiler/plugins-loader.ts +++ b/lib/compiler/plugins-loader.ts @@ -1,6 +1,5 @@ import { join } from 'path'; import * as ts from 'typescript'; -import { isObject } from 'util'; import { CLI_ERRORS } from '../ui'; const PLUGIN_ENTRY_FILENAME = 'plugin'; @@ -31,7 +30,9 @@ export interface MultiNestCompilerPlugins { export class PluginsLoader { public load(plugins: PluginEntry[] = []): MultiNestCompilerPlugins { const pluginNames = plugins.map((entry) => - isObject(entry) ? (entry as PluginAndOptions).name : (entry as string), + entry !== null && typeof entry === 'object' + ? (entry as PluginAndOptions).name + : (entry as string), ); const nodeModulePaths = [ join(process.cwd(), 'node_modules'), @@ -63,9 +64,10 @@ export class PluginsLoader { if (!plugin.before && !plugin.after && !plugin.afterDeclarations) { throw new Error(CLI_ERRORS.WRONG_PLUGIN(pluginNames[index])); } - const options = isObject(plugins[index]) - ? (plugins[index] as PluginAndOptions).options || {} - : {}; + const options = + plugins[index] !== null && typeof plugins[index] === 'object' + ? (plugins[index] as PluginAndOptions).options || {} + : {}; plugin.before && beforeHooks.push(plugin.before.bind(plugin.before, options)); plugin.after && afterHooks.push(plugin.after.bind(plugin.after, options)); From e64480e68258170ef5fe14ba34130e02ad9d57ba Mon Sep 17 00:00:00 2001 From: Antonio Tripodi Date: Mon, 7 Nov 2022 16:18:19 +0100 Subject: [PATCH 2/3] Update lib/compiler/plugins-loader.ts Co-authored-by: Kamil Mysliwiec --- lib/compiler/plugins-loader.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/compiler/plugins-loader.ts b/lib/compiler/plugins-loader.ts index 1dd2226d7..1dca86795 100644 --- a/lib/compiler/plugins-loader.ts +++ b/lib/compiler/plugins-loader.ts @@ -30,9 +30,7 @@ export interface MultiNestCompilerPlugins { export class PluginsLoader { public load(plugins: PluginEntry[] = []): MultiNestCompilerPlugins { const pluginNames = plugins.map((entry) => - entry !== null && typeof entry === 'object' - ? (entry as PluginAndOptions).name - : (entry as string), + entry ? (entry as PluginAndOptions)?.name : (entry as string) ); const nodeModulePaths = [ join(process.cwd(), 'node_modules'), From 6b4bf6e2e0acb0aed2dbcc70095d96743bb3ee44 Mon Sep 17 00:00:00 2001 From: Kamil Mysliwiec Date: Tue, 27 Dec 2022 11:36:37 +0100 Subject: [PATCH 3/3] Update lib/compiler/plugins-loader.ts Co-authored-by: Micael Levi L. Cavalcante --- lib/compiler/plugins-loader.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/compiler/plugins-loader.ts b/lib/compiler/plugins-loader.ts index 1dca86795..1e5de8eb0 100644 --- a/lib/compiler/plugins-loader.ts +++ b/lib/compiler/plugins-loader.ts @@ -62,10 +62,7 @@ export class PluginsLoader { if (!plugin.before && !plugin.after && !plugin.afterDeclarations) { throw new Error(CLI_ERRORS.WRONG_PLUGIN(pluginNames[index])); } - const options = - plugins[index] !== null && typeof plugins[index] === 'object' - ? (plugins[index] as PluginAndOptions).options || {} - : {}; + const options = plugins[index]?.options || {}; plugin.before && beforeHooks.push(plugin.before.bind(plugin.before, options)); plugin.after && afterHooks.push(plugin.after.bind(plugin.after, options));