diff --git a/.gitattributes b/.gitattributes index a9c9b80a6..86a001342 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ *.sh text eol=lf parameters.txt text eol=lf protoc-gen-dump text eol=lf +protoc-gen-ts_proto text eol=lf diff --git a/aliases.sh b/aliases.sh index 27eeed544..7808edc1d 100644 --- a/aliases.sh +++ b/aliases.sh @@ -2,10 +2,23 @@ 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 +# Alias docker-compose to make it usable from anywhere. function _docker-compose() { docker-compose -f $PROJECT_ROOT/docker-compose.yml "$@"; } -function protoc() { _docker-compose run --rm protoc "$@"; } -function protoc-sh() { _docker-compose run --rm --entrypoint sh -- protoc "$@"; } +# 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; } -function ts-protoc { protoc --plugin=$PROJECT_ROOT_DOCKER/protoc-gen-ts_proto "$@"; } + +# 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 "$@"; +} diff --git a/docker-compose.yml b/docker-compose.yml index 6726a4e3e..33d1da732 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,3 +6,4 @@ services: dockerfile: "protoc.Dockerfile" volumes: - ".:/ts-proto" + - "${PWD:-.}:/host"