#!/usr/bin/env bash

# ./edit ru <- tutorial language: RU, server: EN
# ./edit ru ru <- tutorial language: RU, server: RU

: ${1?"Usage: $0 <tutorial language> [<server language>]"}

export NODE_LANG="${2:-en}"
export TUTORIAL_LANG=$1
export NODE_ENV=production
export TUTORIAL_EDIT=1
export NODE_PRESERVE_SYMLINKS=1

# Use a local bunyan if no other is found in the current environment
if ! [ -x "$(command -v bunyan)" ]; then
  export PATH="$PATH:./node_modules/bunyan/bin"
fi

npm --silent run -- gulp edit | bunyan -o short -l debug

