Created
May 10, 2020 13:46
-
-
Save badsyntax/75fcf5e8da5c23d9fed43c6332f56ad1 to your computer and use it in GitHub Desktop.
Generate grpc-js typescript files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
OUT_DIR="./out" | |
TS_OUT_DIR="./src" | |
IN_DIR="./proto" | |
PROTOC="$(npm bin)/grpc_tools_node_protoc" | |
PROTOC_GEN_TS="$(npm bin)/protoc-gen-ts" | |
mkdir -p "$OUT_DIR" | |
$PROTOC \ | |
-I=./ \ | |
--plugin=protoc-gen-ts=$PROTOC_GEN_TS \ | |
--js_out=import_style=commonjs:$OUT_DIR \ | |
--grpc_out=:$OUT_DIR \ | |
--ts_out=service=grpc-node:$TS_OUT_DIR \ | |
"$IN_DIR"/service.proto | |
sed -i "" -e \ | |
"s/require('grpc')/require('@grpc\/grpc-js')/g" \ | |
"$OUT_DIR/$IN_DIR/"* | |
sed -i "" -e \ | |
"s/from \"grpc\"/from \"@grpc\/grpc-js\"/g" \ | |
"$TS_OUT_DIR/$IN_DIR/"* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment