shiyanhui / hero

A handy, fast and powerful go template engine.
https://shiyanhui.github.io/hero
Other
1.57k stars 96 forks source link

Using -watch, on save, "no such file or directory" #81

Closed J7mbo closed 4 years ago

J7mbo commented 4 years ago

The following command works:

hero -source="./internal/public/html" -dest="./internal/template/"

As soon as I append watch on the end, it waits for a change in the html file as expected.

However, when I make a change and then save the html file, I get the following:

2020/02/19 21:56:21 stat /Users/jimbo/Documents/Dev/app/internal/public/html/body.html~: no such file or directory

...and it crashes.

shiyanhui commented 4 years ago

It seems that body.html~ is a backup file. Delete it and try again.

J7mbo commented 4 years ago

rm /Users/jimbo/Documents/Dev/app/internal/public/html/body.html~

Gives:

rm: /Users/jimbo/Documents/Dev/app/internal/public/html/body.html~: No such file or directory

The file doesn't exist for me to delete it.

J7mbo commented 4 years ago

I solved this. My IDE is generating temporary files. This is also a MacOS thing.

In order to use this tool, I have to go into my IntelliJ IDE (in my case, Jetbrains) and disable "Use 'safe write' (save changes to a temporary file first)".

image

The problem is, I want safe write and shouldn't have to disable it to use this library as I don't have this problem with other file watchers :).

Can there be a solution where all files with a Tilda (~) at the end are ignored?

J7mbo commented 4 years ago

I don’t think Go has a mature enough ecosystem to support templating like this. Closing for now and using a better tool for the job.