grpc_tools_node_protoc_ts
grpc_tools_node_protoc_ts copied to clipboard
protoc-gen-ts does not end process in powershell
Summary
The grpc generators creates all the grpc js/ts artifacts in < 2 seconds, but it doesn't end the powershell script execution which can be problematic when it's chained with other npm commands.
Current Versions:
"grpc": "^1.24.3"
"grpc-tools": "^1.9.1"
"grpc_tools_node_protoc_ts": "^5.0.1"
Repro steps:
- Create a grpc typescript project
npm install grpc_tools_node_protoc_ts --save-dev
- Create a ./proto directory, use a sample .proto file: https://github.com/blokur/grpc-ts-demo/blob/master/proto/songs.proto
- Use this script to generate the proto files:
param (
[Parameter(Mandatory=$true)][string]$basedir
)
Push-Location $basedir
$FullPath=$PWD
$PROTOGEN_DIR="./src/protogen"
mkdir -force $PROTOGEN_DIR
$PROTOC_GEN_TS_PATH="node_modules/.bin/protoc-gen-ts.cmd"
$GRPC_TOOLS_NODE_PROTOC_PLUGIN="node_modules/.bin/grpc_tools_node_protoc_plugin.cmd"
./node_modules/.bin/grpc_tools_node_protoc `
--js_out=import_style=commonjs,binary:"$PROTOGEN_DIR" `
--ts_out="$PROTOGEN_DIR" `
--grpc_out="$PROTOGEN_DIR" `
--plugin=protoc-gen-grpc="$FullPath/$GRPC_TOOLS_NODE_PROTOC_PLUGIN" `
-I ./proto `
./proto/*.proto
# TypeScript code generation
./node_modules/.bin/protoc-gen-ts `
--plugin=protoc-gen-ts="$FullPath/$PROTOC_GEN_TS_PATH" `
--ts_out="$PROTOGEN_DIR" `
-I ./proto
./proto/*.proto
Pop-Location
Command: build-protos.ps1 -basedir .\<project root>
4. Powershell does not end process after protoc-gen-ts
Hi @ihl396 ,
I have no windows PC, so it's difficult for me to debug the issue of PowerShell. I would leave this issue open to see is there anybody else could solve your issue.
@agreatfool powershell has been cross-platform for a while now: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1
Oh, good to know