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

Feature request: don't remove files on --watch #83

Open
DaniGuardiola opened this issue Jul 5, 2024 · 4 comments
Open

Feature request: don't remove files on --watch #83

DaniGuardiola opened this issue Jul 5, 2024 · 4 comments

Comments

@DaniGuardiola
Copy link

I have a watch script that runs tshy --watch and some CSS compilation in parallel. In the output (dist/esm and dist/commonjs), js files live alongside CSS files. In my normal build script, I simply execute tshy before the CSS compilation, but when in watch mode, tshy detects a filesystem change when a CSS file is written, and then proceeds to remove it. I would like for tshy to leave these files untouched. A reasonable opt-in setting would be okay for me.

@isaacs
Copy link
Owner

isaacs commented Jul 8, 2024

Would it be possible to just put the css somewhere else? The problem is that if it doesn't delete the dist folder prior to building, then it's too easy to end up with deleted/renamed files sticking around forever.

@DaniGuardiola
Copy link
Author

Could it instead just remove js/jsx files (and any empty directories resulting from it? Moving the CSS somewhere else is not a viable option unfortunately.

@DaniGuardiola
Copy link
Author

I took a look around the code. I think this could be a clean implementation:

  • Add an option to sync-content that allows specifying a condition for deleting files or directories, either through a whitelist or blacklist approach.
  • In tshy, add an option to the build script that, when syncing tshy-build with dist, only cleans up js/d.ts/etc files (and directories that only contain such files or are empty). This option could be "private", as it probably doesn't make much sense for single runs (user can just do any other dist manipulation afterward).
  • Provide an option in --watch along the lines of "clean only js files" or "retain external files" or whatever naming is clearest.

I'd be happy to attempt a contribution. Would you be willing to accept it? Do you have any alternative suggestions?

@isaacs
Copy link
Owner

isaacs commented Jul 17, 2024

Yeah, I like the idea of giving sync-content a filter on which files to care about. Maybe a glob pattern or regexp or something.

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

No branches or pull requests

2 participants