mirror of
https://github.com/plebbit/seedit.git
synced 2026-04-17 13:48:43 -04:00
21 lines
590 B
Bash
Executable File
21 lines
590 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# afterFileEdit hook: Run Corepack-managed Yarn install when package.json is changed
|
|
# Receives JSON via stdin: {"file_path": "...", "edits": [...]}
|
|
|
|
input=$(cat)
|
|
file_path=$(echo "$input" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*:.*"\([^"]*\)"/\1/')
|
|
|
|
if [ -z "$file_path" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$file_path" = "package.json" ]; then
|
|
repo_root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
|
cd "$repo_root" || exit 0
|
|
echo "package.json changed - running corepack yarn install to update yarn.lock..."
|
|
corepack yarn install
|
|
fi
|
|
|
|
exit 0
|