Skip to content

Fix the --target/-t option of yarn dist#1593

Open
savetheclocktower wants to merge 3 commits into
masterfrom
fix-dist-targets
Open

Fix the --target/-t option of yarn dist#1593
savetheclocktower wants to merge 3 commits into
masterfrom
fix-dist-targets

Conversation

@savetheclocktower

@savetheclocktower savetheclocktower commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

…and eliminate the positional [platform] argument.

I thought I’d have a crack at revisiting #1397 with a bit more care. We already have code for deciding which targets to build; it just misfires a bit.

  1. All experimentation I’ve done suggests that you can’t actually do a cross-platform build. So the optional/positional platform argument (which never worked anyway because we used yargs wrong) is eliminated. We’ll just filter the options to include only the platform you’re actually on, since that’s what happens in effect anyway.
  2. Since platform wasn’t implemented properly, the target keyword switch didn’t work either, since whatToBuild bailed early when platform was missing. And then we didn’t filter targets correctly anyway, so that needed fixing as well.
  3. Allow customization of output targets in script/electron-builder.js #1397’s target names overlapped only somewhat with the official target names from electron-builder. This time around I’m just reusing the target names that are already defined.

--target still accepts only one target — but if people want it to accept multiple (e.g., --target=rpm,tar.gz), that could be accomplished rather easily. (Now it supports multiple comma-separated targets.)

Testing

This works just fine in my experiments, but please feel free to test it out with commands like

yarn dist --target=dmg

or an appropriate target for your platform.

…and eliminate the positional `[platform]` argument.
],
target: [
{ target: 'dmg' },
{ target: 'zip' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have here also dir as a plain unpacked directory target?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do that, it gets built by default when -t is omitted.

I'll consider reworking this to allow specifying of targets that are not there by default.

@ottok

ottok commented Jun 2, 2026

Copy link
Copy Markdown

In general looks good to me.

Note that your commit message subject line is too long and e.g. GitHub renders it like this:

image

https://optimizedbyotto.com/post/good-git-commit/#2-the-title-should-be-descriptive-yet-terse-and-not-too-long

@savetheclocktower

Copy link
Copy Markdown
Contributor Author

In general looks good to me.

Note that your commit message subject line is too long and e.g. GitHub renders it like this:
image

https://optimizedbyotto.com/post/good-git-commit/#2-the-title-should-be-descriptive-yet-terse-and-not-too-long

That's exactly how I wrote, it, yes. :)

@savetheclocktower

Copy link
Copy Markdown
Contributor Author

OK, just updated the PR to allow the user to specify arbitrary targets (comma-separated if more than one is desired) instead of limiting the user to the set of targets that are already present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants