Closed brikis98 closed 3 months ago
Any plans on fixing this? This seems to be an issue especially on Windows for even the simplest of text files.. Perhaps if there's no "better" way, then this can be overridable via configuration? E.g. a flag to ignore the binary/text file check if all we're doing is templating text files, or even something more granular such as categorizing files manually into binary vs textual
Additionally, on some OS, e.g. Ubuntu 26 , running file -b --mime some.js
returns a javascript mime type
application/javascript; charset=us-ascii
so js/ts is currently excluded via https://github.com/gruntwork-io/boilerplate/blob/441f030657d69b7da4113e0b7963b30a6bc7b455/util/file.go#L38
@denis256 Do you think you could look into this? The ideal solution would be some Go library that does a good job of disambiguating between binary & text files.
Will take a look
Released improvement in https://github.com/gruntwork-io/boilerplate/releases/tag/v0.5.13
Thanks, this sorted my issue
Describe the bug
boilerplate
has to distinguish between text files, which are passed through the Go templating engine, and binary files, which are copied without any changes. It tries to do this using thefile
command, if it's available on the computer:https://github.com/gruntwork-io/boilerplate/blob/d323184f59f1eb937fb9b6f7fb8ffb8ba1fc9fb5/util/file.go#L41-L51
On computers without
file
, it falls back to Go'shttp.DetectContentType
, which works well for the most part, but sometimes, it fails: for example, it fails on.hcl
files, treating them as binary! As a result, the Go templating in the.hcl
files doesn't get processed.To Reproduce Run
boilerplate
on a system that doesn't havefile
installed and have it process a.hcl
file in the--template-folder
.Expected behavior
boilerplate
should:file
is not installed and we're falling back tohttp.DetectContentType
.Additional context Originally reported in https://gruntwork-io.slack.com/archives/CJ39EV0KW/p1669017123927079.