#!/bin/bash

# Get the directory of the current script.
PREFIX_DIR=$(dirname "${BASH_SOURCE[0]}")

# Make PREFIX_DIR absolute.
if [[ $(uname) == 'Linux' ]]; then
  PREFIX_DIR=$(readlink -f "${PREFIX_DIR}")
else
  pushd "${PREFIX_DIR}"
  PREFIX_DIR=$(pwd -P)
  popd
fi

# Move one level up to reach the conda environment prefix.
PREFIX_DIR=$(dirname "${PREFIX_DIR}")

# Start the server using Node.js, passing all user arguments.
node "${PREFIX_DIR}/share/sagemaker-code-editor/out/server-main.js" "$@"
