#!/bin/bash

# Put our vendored version of node/yarn on the path. Can be helpful if you need
# quick access on a machine that does not have Node installed separately.

# Eg:
# $ . tools/node-env
# $ (cd ts && yarn)

BAZEL_EXTERNAL=$(bazel info output_base --ui_event_filters=-INFO)/external

if [[ "$OSTYPE" == "darwin"* ]]; then
   if [ "$(arch)" == "i386" ]; then
      export PATH="$BAZEL_EXTERNAL/nodejs_darwin_amd64/bin:$PATH"
   else
      export PATH="$BAZEL_EXTERNAL/nodejs_darwin_arm64/bin:$PATH"
   fi
else
   if [ "$(arch)" == "aarch64" ]; then
      export PATH="$BAZEL_EXTERNAL/nodejs_linux_arm64/bin:$PATH"
   else
      export PATH="$BAZEL_EXTERNAL/nodejs_linux_amd64/bin:$PATH"
   fi
fi
