Skip to content

Instantly share code, notes, and snippets.

@Idnan
Created November 2, 2019 09:01
Show Gist options
  • Save Idnan/d521870ef2fcd0e406fa7ab521b3407f to your computer and use it in GitHub Desktop.
Save Idnan/d521870ef2fcd0e406fa7ab521b3407f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BASEDIR=$(dirname "$0")
cd "${BASEDIR}"/../
PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts"
GRPC_TOOLS_NODE_PROTOC_PLUGIN="./node_modules/.bin/grpc_tools_node_protoc_plugin"
GRPC_TOOLS_NODE_PROTOC="./node_modules/.bin/grpc_tools_node_protoc"
for f in ./src/proto/*; do
# skip the non proto files
if [ "$(basename "$f")" == "index.ts" ]; then
continue
fi
# loop over all the available proto files and compile them into respective dir
# JavaScript code generating
${GRPC_TOOLS_NODE_PROTOC} \
--js_out=import_style=commonjs,binary:"${f}" \
--grpc_out="${f}" \
--plugin=protoc-gen-grpc="${GRPC_TOOLS_NODE_PROTOC_PLUGIN}" \
-I "${f}" \
"${f}"/*.proto
${GRPC_TOOLS_NODE_PROTOC} \
--plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \
--ts_out="${f}" \
-I "${f}" \
"${f}"/*.proto
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment