fix: handle os.ErrExist on subsequent reruns #30
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue reported by other users a while ago on #21, which pointed out that running the same executable / script several times (e.g. when changing or updating the same diagram) results in
os.ErrExist
errors considering that thego-diagrams
and innerassets
folders already existed.This is a known error returned in
os.MkDir
andos.MkDirAll
that can be checked with an (optionally in-line)errors.Is
call.These changes are applied to the
diagram
andcmd/gen
package, where (black-box) tests were added to thediagram
package, and the assets regenerated (withgo run ./cmd/gen
).This PR also updates all dependencies to their latest versions; removes the usage of
ioutil
(as a deprecated package, if favor ofos
functions); and regenerates all assets. The later is an important step to mention since it seems these were generated in a different order in some symbols. I am unsure of the reason why (didn't look into that) however I can also remove theassets
folder commit in particular, if you wish to skip changes to that package. I believe it's always a good idea to regen on changes, but there is a context to it too.There are other details that I see potential in improvement, and I wish to contribute to this repository, but all in their due PRs and topics :D these changes should only comprehend the issue for the existing files when re-rendering a diagram.