snivilised / astrolib

Go template for library modules with i18n support
MIT License
0 stars 0 forks source link

fix sed failure in auto-check #43

Closed plastikfan closed 4 months ago

plastikfan commented 4 months ago

auto-check ---> 😎 OWNER: snivilised ---> 🧰 REPO: traverse

🎯 ---> title: 💥 update-workflow-names ✅ ---> file pattern: *.yml ✅ ---> folder: .github/workflows ✅ ---> target: name: astrolib ✅ ---> replacement: name: Traverse sed: 1: ".github/workflows/relea ...": invalid command code . sed: 1: ".github/workflows/ci-wo ...": invalid command code . sed: 1: ".github/workflows/auto- ...": invalid command code . !!! ⛔ Aborted! update-all-generic failed for snivilised/traverse:

plastikfan commented 4 months ago

old code(function update-all-generic):

find $folder -name "$name" -type f -print -exec sed -i "s/${target}/${replacement}/g" {} +

  if [ $? -ne 0 ]; then
    echo "!!! â›” Aborted! update-all-generic failed for $owner/$repo:"
    return 1
  fi

new code(function update-all-generic):

find "$folder" -name "$name" -type f -print0 | while IFS= read -r -d '' file; do
    echo "Processing file: $file"
    if ! sed "s/${target}/${replacement}/g" "$file" > "$file.tmp" && mv "$file.tmp" "$file"; then
      echo "!!! â›” Sed failed for $file"
      return 1
    fi
  done

It looks like there was a problem in how sed handles files with names that contain - (ci-workflow.xml, release-workflow)