-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_codemods.sh
executable file
·35 lines (29 loc) · 1.15 KB
/
run_codemods.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Check if at least one file is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <file1> <file2> ... <fileN>"
exit 1
fi
# Array of jscodemod scripts (from 1*.js to 7*.js), assuming they are located in the same directory as this script
scripts=("$SCRIPT_DIR"/1*.js "$SCRIPT_DIR"/2*.js "$SCRIPT_DIR"/3*.js "$SCRIPT_DIR"/4*.js "$SCRIPT_DIR"/5*.js "$SCRIPT_DIR"/6*.js "$SCRIPT_DIR"/7*.js "$SCRIPT_DIR"/8*.js "$SCRIPT_DIR"/9*.js)
# Loop over each jscodemod script
for script in "${scripts[@]}"; do
# Ensure the script exists before running
if [ -f "$script" ]; then
echo "Running $script on provided files..."
# Loop over all the provided files and run the current script on each file
for file in "$@"; do
if [ -f "$file" ]; then
echo "Processing file: $file"
npx jscodeshift --parser=tsx -t "$script" "$file"
else
echo "File $file does not exist. Skipping."
fi
done
else
echo "Script $script not found. Skipping."
fi
done
echo "All scripts have been run on the provided files."