refactor: support invoke tasks.py from other dir
This commit is contained in:
parent
6839c4f573
commit
9d77f65495
@ -1,6 +1,7 @@
|
|||||||
from invoke import task
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from invoke import task
|
||||||
|
|
||||||
ROOT = Path(__file__).parent
|
ROOT = Path(__file__).parent
|
||||||
PB_ROOT = ROOT / "pb"
|
PB_ROOT = ROOT / "pb"
|
||||||
|
|
||||||
@ -27,13 +28,14 @@ def gen(c, target="types"):
|
|||||||
"""
|
"""
|
||||||
Generate gRPC client code.
|
Generate gRPC client code.
|
||||||
"""
|
"""
|
||||||
outDir = "gen/types"
|
outDir = "gen/" + target
|
||||||
paths = Path(PB_ROOT).glob('**/*.proto')
|
paths = Path(PB_ROOT).glob('**/*.proto')
|
||||||
for path in paths:
|
for path in paths:
|
||||||
# because path is object not string
|
# because path is object not string
|
||||||
pathStr = str(path)
|
pathStr = str(path)
|
||||||
print("Generating for", pathStr)
|
print("Generating for", pathStr)
|
||||||
|
cmd = Path(c.run("npm bin").stdout.rstrip()).joinpath("proto-loader-gen-types")
|
||||||
c.run(
|
c.run(
|
||||||
"npx proto-loader-gen-types --includeComments --grpcLib @grpc/grpc-js -I pb -O {} {}"
|
"{} --includeComments --grpcLib @grpc/grpc-js -I pb -O {} {}"
|
||||||
.format(outDir, pathStr)
|
.format(cmd, outDir, pathStr)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user