thoughtbot / belt

Belt is a CLI for starting a new React Native Expo app and will even keep your pants secure as you continue development.
MIT License
131 stars 3 forks source link

Fix corrupt images #55

Closed stevehanson closed 3 months ago

stevehanson commented 3 months ago

There is an issue where the assets images were all corrupted in the generated Belt app. This is occurring because Belt reads files as utf-8 text and then writes them when copying. It isn't handling binary files appropriately. The only binary files I’m aware of right now are in templates/boilerplate/assets.

To reproduce the original issue, from Belt project dir:

node bin/belt.js NewApp
cd builds/NewApp
open assets/splash.png
# corrupted image

This updates the copyTemplateDirectory function to use fs.copy for binary files (currently defined using an array of filenames that we identify as binary, but we might want something more robust in the future) instead of reading the file, optionally transforming it, and then writing it.