forked from zeta-chain/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotoc-gen-typescript.sh
More file actions
executable file
·38 lines (32 loc) · 1.02 KB
/
protoc-gen-typescript.sh
File metadata and controls
executable file
·38 lines (32 loc) · 1.02 KB
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
36
37
38
#!/usr/bin/env bash
DIR="typescript"
rm -rf $DIR
(cd proto && buf generate --template buf.ts.yaml)
cat <<EOL > $DIR/package.json
{
"name": "@zetachain/node-types",
"version": "0.0.0-set-on-publish",
"description": "",
"main": "",
"keywords": [],
"author": "ZetaChain",
"license": "MIT"
}
EOL
# Loop through all directories recursively
find "$DIR" -type d | while read -r dir; do
# Check if there are any .d.ts files in the directory
if ls "$dir"/*.d.ts &> /dev/null; then
# Create or clear index.d.ts in the directory
> "$dir/index.d.ts"
# Loop through all .d.ts files in the directory
for file in "$dir"/*.d.ts; do
# Extract the base filename without the .d.ts extension
base_name=$(basename "$file" .d.ts)
# If the base name is not 'index', append the export line to index.d.ts
if [ "$base_name" != "index" ]; then
echo "export * from \"./$base_name\";" >> "$dir/index.d.ts"
fi
done
fi
done