Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaultName for saving .js or .zip #178

Merged
merged 3 commits into from
Jan 17, 2025
Merged

Add defaultName for saving .js or .zip #178

merged 3 commits into from
Jan 17, 2025

Conversation

North101
Copy link

Allows exporting defaultName which will be used when saving .js or .zip files

Fixes #177

Copy link
Owner

@sgenoud sgenoud left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Can you remove the code that changes the script name (or change it in a way that it actually takes the default name)

Always great to see people contributing!

export default (code, fileName) => {
fileName = fileName ?? 'replicad-script'
export default async (code, fileName) => {
fileName = fileName
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure this does something? I feel like it always take the name of the first export

Copy link
Author

Choose a reason for hiding this comment

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

    const shapeName =
      store.currentMesh.length === 1 ? store.currentMesh[0]?.name : null;
    return downloadCode(store.code.current, shapeName);

It'll use the shape name if there is only 1 shape and only if it has a name, then it will use the defaultName then it will fallback to replicad-script.

Copy link
Author

@North101 North101 Jan 11, 2025

Choose a reason for hiding this comment

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

Would defaultName ?? shapeName ?? 'replicad-script' be a better order?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I think this would be a better order (as all shapes get a name by default).

@sgenoud
Copy link
Owner

sgenoud commented Jan 17, 2025

Thanks! I will do a couple of changes on my end to support the case where there is only one shape.

@sgenoud sgenoud merged commit f542d84 into sgenoud:main Jan 17, 2025
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.

Change .zip filename
2 participants