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 option to convert on save #157

Open
onetrev opened this issue Apr 26, 2023 · 10 comments
Open

Add option to convert on save #157

onetrev opened this issue Apr 26, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request feature

Comments

@onetrev
Copy link

onetrev commented Apr 26, 2023

I was thinking it would be very handy to have an option to convert current YAML file on save. I'm guessing this could help others too? My use case is I'm using this extension because working with theme.json to develop a large custom WP theme is a nightmare. It's much easier in YAML.

I already have keepOriginalFiles and overwriteExistentFiles as always. I'm thinking that if the above feature is added these two should be always by default then since that would be the natural work flow right? Thanks!

@onetrev onetrev added enhancement New feature or request feature labels Apr 26, 2023
@hilleer
Copy link
Owner

hilleer commented Apr 26, 2023

Hey @onetrev

Thanks for the feature request! 🥳

Just to get it right: So flow would be like this:

  1. Set an option/config value e.g. convertOnSave: true
  2. Create a file - yaml or json
  3. write something
  4. Save file - automatically converts to the counterpart (yaml --> json, json --> yaml)

Should the original file be kept in this case? 🤔 Maybe it would make sense to keep keepOriginalFiles to define such.

@onetrev
Copy link
Author

onetrev commented Apr 26, 2023

G'day! Yes you nailed it. That's exactly what I was thinking. Most definitely the original file should be kept in this case. 100%.

It wouldn't really make sense to not keep the original file was what I was thinking, since it would defeat the purpose of this option. If you didn't keep it, then once you save your original file once, it would be gone and there'd be nothing else to convert on save. 🙂

@hilleer
Copy link
Owner

hilleer commented Apr 26, 2023

Cool! I will consider it an see what is possible.

What if you do it like described above but additionally:

  1. Make some more changes to source file.
  2. Save file - automatically convert. Does it overwrite the (already) existent file automatically? Would it warn about it? 👀 Or would it depend on the mentioned setting overwriteExistentFiles?

@onetrev
Copy link
Author

onetrev commented Apr 27, 2023

Awesome, thanks for considering this!

Good questions. I think safety first, it should warn you about overwriting the file, unless yes you have overwriteExistentFiles as always. Good idea!

@gyurmey2
Copy link

It would be great!

@mgawe
Copy link

mgawe commented May 13, 2024

Hi @hilleer, is there any chance to implement this?

@hilleer
Copy link
Owner

hilleer commented May 13, 2024

Hi @hilleer, is there any chance to implement this?

Definitely. I have just been busy. PRs are also welcome but otherwise I'll try to find some time soon 🙂 🤞

@mgawe
Copy link

mgawe commented May 14, 2024

I haven't found a better VSC extension (YAML to JSON), and this would just be icing on the cake. Thanks!

@gyurmey2
Copy link

gyurmey2 commented Jul 5, 2024

Hi @hilleer, I just wanted to ask if this is even planned? And I just want to make sure ;)

@hilleer
Copy link
Owner

hilleer commented Jul 5, 2024

Hi @hilleer, I just wanted to ask if this is even planned? And I just want to make sure ;)

Yes. But I haven't had time to do it unfortunately 🕐 Pull requests are more than welcomed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature
Projects
None yet
Development

No branches or pull requests

4 participants