From 7574b364901ec429220dbe7076184585a99529a5 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 8 Oct 2024 14:40:00 -0700 Subject: [PATCH] fix: log correct directory when hook moves artifacts (#3730) --- packages/api/core/src/api/make.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/api/core/src/api/make.ts b/packages/api/core/src/api/make.ts index d9c0b9cdb7..c03b43e5ad 100644 --- a/packages/api/core/src/api/make.ts +++ b/packages/api/core/src/api/make.ts @@ -317,10 +317,28 @@ export const listrMake = ( task: childTrace>>({ name: 'run-postMake-hook', category: '@electron-forge/core' }, async (_, ctx, task) => { // If the postMake hooks modifies the locations / names of the outputs it must return // the new locations so that the publish step knows where to look + const originalOutputs = JSON.stringify(ctx.outputs); ctx.outputs = await runMutatingHook(ctx.forgeConfig, 'postMake', ctx.outputs); + + let outputLocations = [path.resolve(ctx.actualOutDir, 'make')]; + if (originalOutputs !== JSON.stringify(ctx.outputs)) { + const newDirs = new Set(); + const artifactPaths = []; + for (const result of ctx.outputs) { + for (const artifact of result.artifacts) { + newDirs.add(path.dirname(artifact)); + artifactPaths.push(artifact); + } + } + if (newDirs.size <= ctx.outputs.length) { + outputLocations = [...newDirs]; + } else { + outputLocations = artifactPaths; + } + } receiveMakeResults?.(ctx.outputs); - task.output = `Artifacts available at: ${chalk.green(path.resolve(ctx.actualOutDir, 'make'))}`; + task.output = `Artifacts available at: ${chalk.green(outputLocations.join(', '))})}`; }), rendererOptions: { persistentOutput: true,