diff --git a/grpc/tasks.py b/grpc/tasks.py index a6496fd..4e8fccc 100644 --- a/grpc/tasks.py +++ b/grpc/tasks.py @@ -1,6 +1,7 @@ -from invoke import task from pathlib import Path +from invoke import task + ROOT = Path(__file__).parent PB_ROOT = ROOT / "pb" @@ -27,13 +28,14 @@ def gen(c, target="types"): """ Generate gRPC client code. """ - outDir = "gen/types" + outDir = "gen/" + target paths = Path(PB_ROOT).glob('**/*.proto') for path in paths: # because path is object not string pathStr = str(path) - print("Generating f or", pathStr) + print("Generating for", pathStr) + cmd = Path(c.run("npm bin").stdout.rstrip()).joinpath("proto-loader-gen-types") c.run( - "npx proto-loader-gen-types --includeComments --grpcLib @grpc/grpc-js -I pb -O {} {}" - .format(outDir, pathStr) + "{} --includeComments --grpcLib @grpc/grpc-js -I pb -O {} {}" + .format(cmd, outDir, pathStr) )