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

Method getHooks

packages/plugin/webpack/src/WebpackPlugin.ts:194–557  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 }
193
194 getHooks(): ForgeMultiHookMap {
195 return {
196 preStart: [
197 namedHookWithTaskFn<'preStart'>(async (task) => {
198 if (this.alreadyStarted) return;
199 this.alreadyStarted = true;
200
201 await fs.remove(this.baseDir);
202
203 const logger = new Logger(this.loggerPort);
204 this.loggers.push(logger);
205 await logger.start();
206
207 return task?.newListr([
208 {
209 title: 'Compiling main process code',
210 task: async () => {
211 await this.compileMain(true, logger);
212 },
213 rendererOptions: {
214 timer: { ...PRESET_TIMER },
215 },
216 },
217 {
218 title: 'Launching dev servers for renderer process code',
219 task: async (_, task) => {
220 await this.launchRendererDevServers(logger);
221 task.output = `Output Available: ${chalk.cyan(`http://localhost:${this.loggerPort}`)}\n`;
222 },
223 rendererOptions: {
224 persistentOutput: true,
225 timer: { ...PRESET_TIMER },
226 },
227 },
228 ]);
229 }, 'Preparing webpack bundles'),
230 ],
231 prePackage: [
232 namedHookWithTaskFn<'prePackage'>(
233 async (task, config, platform, arch) => {
234 if (!task) {
235 throw new Error(
236 'Incompatible usage of webpack-plugin prePackage hook',
237 );
238 }
239
240 this.isProd = true;
241 await fs.remove(this.baseDir);
242
243 // TODO: Figure out how to get matrix from packager
244 const arches: string[] = Array.from(
245 new Set(
246 arch
247 .split(',')
248 .reduce<
249 string[]
250 >((all, pArch) => (pArch === 'universal' ? all.concat(['arm64', 'x64']) : all.concat([pArch])), []),
251 ),

Callers

nothing calls this directly

Calls 5

startMethod · 0.95
getElectronVersionFunction · 0.90
namedHookWithTaskFnFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected