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

Decouple core from side-effects #8

Open
roberto-red opened this issue Oct 3, 2023 · 0 comments
Open

Decouple core from side-effects #8

roberto-red opened this issue Oct 3, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@roberto-red
Copy link
Contributor

Description

@penpot-export/core currently logs to the console and write files, without any way to control that behaviour for the consumer.

This may be undesired for some use-cases. E.g. someone that wants to hook into the file before it's written to use PostCSS or CSSTree or apply any transformation.

Expected output

Move logging to the CLI. This could be made injecting a logger function. But I'll just prefer to use a generator function in core and use message passing with the CLI, then let the CLI log the way it wants.

Return file contents instead of writing files directly. Expose a function to write files, if the logic happens to be non-trivial. When written as a generator function, each file will be another message yielded. The file path configuration won't be required.

Opportunity

Using a generator function will allow the core transformation to be treated as a thread, and a consumer (like the CLI) will gain great abilities like pause and resume execution at will. This may be used to make the generation interactive or quiet, or expose some user hooks.

@roberto-red roberto-red added the enhancement New feature or request label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant