-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathremove-type.sh
More file actions
executable file
·29 lines (25 loc) · 931 Bytes
/
remove-type.sh
File metadata and controls
executable file
·29 lines (25 loc) · 931 Bytes
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
#!/bin/bash
# Define the list of directories containing package.json files
DIRECTORIES=("packages/*" "plugins/*")
remove_type_field() {
local dir=$1
local package_file="$dir/package.json"
if TYPE=$(jq -r '.type // empty' "$package_file"); then
echo "📦 Removing type field from $package_file"
# Convert to array of key-value pairs, filter out type, convert back while preserving order
jq 'to_entries | map(select(.key != "type")) | from_entries' "$package_file" > "$package_file.tmp" && mv "$package_file.tmp" "$package_file"
echo "$TYPE" > "$package_file.type"
fi
}
# Process all packages
for DIR in ${DIRECTORIES[@]}; do
if [ -f "$DIR/package.json" ]; then
remove_type_field "$DIR"
else
for SUBDIR in $DIR/*; do
if [ -f "$SUBDIR/package.json" ]; then
remove_type_field "$SUBDIR"
fi
done
fi
done