Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: package name override
Browse files Browse the repository at this point in the history
  • Loading branch information
Enda Phelan committed Sep 18, 2020
1 parent c2dffa5 commit 4c6e563
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/graphback/src/loadPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { GraphbackPlugin } from "@graphback/core";

export function loadPlugins(pluginConfig: any): GraphbackPlugin[] {
if (!pluginConfig) {
export function loadPlugins(pluginConfigMap: any): GraphbackPlugin[] {
if (!pluginConfigMap) {
return [];
}

const pluginInstances = [];
for (const pluginLabel of Object.keys(pluginConfig)) {
for (const pluginLabel of Object.keys(pluginConfigMap)) {
let pluginName = pluginLabel;
if (pluginLabel.startsWith('graphback-')) {
// Internal graphback plugins needs rename
pluginName = pluginLabel.replace('graphback-', '@graphback/codegen-');
}
if(config.packageOverride){
pluginName = config.packageOverride;
// override package name
if(pluginConfigMap[pluginLabel].packageNameOverride){
pluginName = pluginConfigMap[pluginLabel].packageNameOverride;
}

try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const plugin = require(pluginName);
if (plugin.Plugin) {
const config = pluginConfig[pluginLabel];
const config = pluginConfigMap[pluginLabel];
pluginInstances.push(new plugin.Plugin(config));
}
else {
Expand Down

0 comments on commit 4c6e563

Please sign in to comment.