Skip to content

Commit 7574b36

Browse files
fix: log correct directory when hook moves artifacts (#3730)
1 parent d6187ad commit 7574b36

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

packages/api/core/src/api/make.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,28 @@ export const listrMake = (
317317
task: childTrace<Parameters<ForgeListrTaskFn<MakeContext>>>({ name: 'run-postMake-hook', category: '@electron-forge/core' }, async (_, ctx, task) => {
318318
// If the postMake hooks modifies the locations / names of the outputs it must return
319319
// the new locations so that the publish step knows where to look
320+
const originalOutputs = JSON.stringify(ctx.outputs);
320321
ctx.outputs = await runMutatingHook(ctx.forgeConfig, 'postMake', ctx.outputs);
322+
323+
let outputLocations = [path.resolve(ctx.actualOutDir, 'make')];
324+
if (originalOutputs !== JSON.stringify(ctx.outputs)) {
325+
const newDirs = new Set<string>();
326+
const artifactPaths = [];
327+
for (const result of ctx.outputs) {
328+
for (const artifact of result.artifacts) {
329+
newDirs.add(path.dirname(artifact));
330+
artifactPaths.push(artifact);
331+
}
332+
}
333+
if (newDirs.size <= ctx.outputs.length) {
334+
outputLocations = [...newDirs];
335+
} else {
336+
outputLocations = artifactPaths;
337+
}
338+
}
321339
receiveMakeResults?.(ctx.outputs);
322340

323-
task.output = `Artifacts available at: ${chalk.green(path.resolve(ctx.actualOutDir, 'make'))}`;
341+
task.output = `Artifacts available at: ${chalk.green(outputLocations.join(', '))})}`;
324342
}),
325343
rendererOptions: {
326344
persistentOutput: true,

0 commit comments

Comments
 (0)