Skip to content

Commit

Permalink
Merge pull request #1851 from nestjs/revert-1802-chore/remove-method-…
Browse files Browse the repository at this point in the history
…deprecated

Revert "chore(): remove method deprecated "
  • Loading branch information
kamilmysliwiec committed Dec 27, 2022
2 parents c52de0a + 29d0d4b commit 51ac4c5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/compiler/plugins-loader.ts
@@ -1,5 +1,6 @@
import { join } from 'path';
import * as ts from 'typescript';
import { isObject } from 'util';
import { CLI_ERRORS } from '../ui';

const PLUGIN_ENTRY_FILENAME = 'plugin';
Expand Down Expand Up @@ -30,7 +31,7 @@ export interface MultiNestCompilerPlugins {
export class PluginsLoader {
public load(plugins: PluginEntry[] = []): MultiNestCompilerPlugins {
const pluginNames = plugins.map((entry) =>
entry ? (entry as PluginAndOptions)?.name : (entry as string)
isObject(entry) ? (entry as PluginAndOptions).name : (entry as string),
);
const nodeModulePaths = [
join(process.cwd(), 'node_modules'),
Expand Down Expand Up @@ -62,7 +63,9 @@ export class PluginsLoader {
if (!plugin.before && !plugin.after && !plugin.afterDeclarations) {
throw new Error(CLI_ERRORS.WRONG_PLUGIN(pluginNames[index]));
}
const options = plugins[index]?.options || {};
const options = isObject(plugins[index])
? (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));
Expand Down

0 comments on commit 51ac4c5

Please sign in to comment.