MCPcopy
hub / github.com/electron/forge / constructor

Method constructor

packages/api/core/src/util/plugin-interface.ts:43–93  ·  view source on GitHub ↗
(dir: string, forgeConfig: ResolvedForgeConfig)

Source from the content-addressed store, hash-verified

41 }
42
43 private constructor(dir: string, forgeConfig: ResolvedForgeConfig) {
44 this._pluginPromise = Promise.all(
45 forgeConfig.plugins.map(async (plugin): Promise<IForgePlugin> => {
46 if (isForgePlugin(plugin)) {
47 return plugin;
48 }
49
50 if (
51 typeof plugin === 'object' &&
52 'name' in plugin &&
53 'config' in plugin
54 ) {
55 const { name: pluginName, config: opts } = plugin;
56 if (typeof pluginName !== 'string') {
57 throw new Error(
58 `Expected plugin[0] to be a string but found ${pluginName}`,
59 );
60 }
61 // eslint-disable-next-line @typescript-eslint/no-explicit-any
62 const Plugin = await importSearch<any>(dir, [pluginName]);
63 if (!Plugin) {
64 throw new Error(
65 `Could not find module with name: ${pluginName}. Make sure it's listed in the devDependencies of your package.json`,
66 );
67 }
68 return new Plugin(opts);
69 }
70
71 throw new Error(
72 `Expected plugin to either be a plugin instance or a { name, config } object but found ${JSON.stringify(plugin)}`,
73 );
74 }),
75 ).then((plugins) => {
76 this.plugins = plugins;
77 for (const plugin of this.plugins) {
78 plugin.init(dir, forgeConfig);
79 }
80 return;
81 });
82 // TODO: fix hack
83 // eslint-disable-next-line @typescript-eslint/no-explicit-any
84 this.config = null as any;
85 Object.defineProperty(this, 'config', {
86 value: forgeConfig,
87 enumerable: false,
88 configurable: false,
89 writable: false,
90 });
91 this.triggerHook = this.triggerHook.bind(this);
92 this.overrideStartLogic = this.overrideStartLogic.bind(this);
93 }
94
95 async triggerHook<Hook extends keyof ForgeSimpleHookSignatures>(
96 hookName: Hook,

Callers

nothing calls this directly

Calls 2

isForgePluginFunction · 0.85
initMethod · 0.65

Tested by

no test coverage detected