alexarchambault/plotly-scala

feature request: support ``overwrite`` flag for generating html plots

Opened this issue · 0 comments

Currently plotly-scala defaults to using addSuffixIfExists=true as the method to deal with files that already exists.

If you want to overwrite the file, you are currently forced to delete it first. That unfortunately does not work if the file is already opened by some other process, like it indeed is the case in Intellij Idea if you serve the html to your favourite browser.

The only change is to extend the "does file exist" check in
https://github.com/alexarchambault/plotly-scala/blob/master/render/jvm/src/main/scala/plotly/Plotly.scala#L115-L117
Adding a Boolean flag overwrite or overwritePath or overwriteIfExists and include it in the check referred above will already fix everything as the used java.nio.file.Files.write() function will indeed overwrite by default.