[Cashtab] Overhaul the addGenerated.sh script
Summary:
This script just doesn't work. Here are some of the fixes:
- Set bash to exit on failure
- Fix the array of files creation/appending
- Use an absolute path for the find root so the script can be run from anywhere
- Only search in src/ to not override the node_modules files
- Use proper quoting to prevent globbing expansion issues in the file names
- Rewrite the array loop so it actually runs on each element, not only the first one
- Build the @generated mark in a variable so the script is not marked as generated
- Use proper indentation
- Add the missing newline at the end of the file
- Make sed compatible with BSD/OSX variant
- Remove the unnecessary function
- Remove the unnecessary exit code
The file being no longer marked as generated, this will let the linter do its magic and help preventing new issues from being introduced.
Ref T2030.
Test Plan:
On both OSX (Catalina) and Linux (Arch):
Remove the @generated mark from some of the files and run the script several times. Check the mark is added where missing but never duplicated.
Reviewers: #bitcoin_abc, bytesofman
Reviewed By: #bitcoin_abc, bytesofman
Subscribers: bytesofman, hungsam
Maniphest Tasks: T2030
Differential Revision: https://reviews.bitcoinabc.org/D10629