Skip to content

Commit

Permalink
chore: let move-function set the function name
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 12, 2024
1 parent 79fe45c commit baf937d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/move-function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ set -e

IFS="/" read -r GROUP FUNC <<< "$1"
DEST="$2"
DEST_FUNC="$FUNC"

# If DEST contains /, update DEST_FUNC and DEST.
if [[ "$DEST" == */* ]]; then
IFS="/" read -r DEST DEST_FUNC <<< "$DEST"
fi

mkdir -p "src/$DEST"
git mv "src/$GROUP/$FUNC.ts" "src/$DEST/$FUNC.ts"
git mv "src/$GROUP/$FUNC.ts" "src/$DEST/$DEST_FUNC.ts"

mkdir -p "docs/$DEST"
git mv "docs/$GROUP/$FUNC.mdx" "docs/$DEST/$FUNC.mdx"
git mv "docs/$GROUP/$FUNC.mdx" "docs/$DEST/$DEST_FUNC.mdx"

mkdir -p "benchmarks/$DEST"
git mv "benchmarks/$GROUP/$FUNC.bench.ts" "benchmarks/$DEST/$FUNC.bench.ts"
git mv "benchmarks/$GROUP/$FUNC.bench.ts" "benchmarks/$DEST/$DEST_FUNC.bench.ts"

mkdir -p "tests/$DEST"
git mv "tests/$GROUP/$FUNC.test.ts" "tests/$DEST/$FUNC.test.ts"
git mv "tests/$GROUP/$FUNC.test.ts" "tests/$DEST/$DEST_FUNC.test.ts"

echo "WARNING: You need to update src/mod.ts to export $FUNC"
echo "WARNING: You need to update src/mod.ts to export \"$DEST/$DEST_FUNC.ts\""

0 comments on commit baf937d

Please sign in to comment.