Page MenuHomePhabricator

[Cashtab] Overhaul the addGenerated.sh script
ClosedPublic

Authored by Fabien on Dec 3 2021, 23:44.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Maniphest Tasks
Restricted Maniphest Task
Commits
rABC8c8d185ef516: [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.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Dec 3 2021, 23:44
Fabien added a task: Restricted Maniphest Task.
bytesofman added subscribers: hungsam, bytesofman.

Based on @hungsam review in D10616 and personal testing/review, green

This revision is now accepted and ready to land.Dec 5 2021, 17:03