forked from stephenh/ts-proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases.sh
30 lines (25 loc) · 950 Bytes
/
aliases.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
PROJECT_ROOT=$(realpath $(dirname "$BASH_SOURCE"))
PROJECT_ROOT_DOCKER="//ts-proto" # double slash to support git bash on windows
# Alias docker-compose to make it usable from anywhere.
function _docker-compose() {
if [ uname -a | grep arm64 ]
then
ARCH=aarch_64
fi
docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@";
}
# Dockerized version of protoc.
function protoc() { _docker-compose run --rm -w //host --entrypoint protoc -- protoc "$@"; }
# Open a shell in the dockerized version of protoc, useful for debugging.
function protoc-sh() { _docker-compose run --rm -w //host -- protoc "$@"; }
# Rebuild the docker image.
function protoc-build() { _docker-compose build protoc; }
# Run protoc with the plugin path pre-set.
function ts-protoc {
if [ ! -d "$PROJECT_ROOT/build" ]; then
echo "Run 'yarn build' first"
return 1
fi
protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@";
}