Files
jj-command-line/jj.sh
T
2024-11-10 01:06:11 -05:00

90 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env zsh
source ~/.bashrc
set -
trap '[[ "$?" == "1" ]] && echo -e "\033[1;31m[jj] ERROR !\033[0m" >&2' EXIT
autoload -U compinit
compinit
jjCpmmandRunPoint=$(echo ${BASH_SOURCE[0]})
function findJJSource {
# @source http://stackoverflow.com/a/246128/330439
local SOURCE="$jjCpmmandRunPoint"
local DIR=""
while [[ -h "$SOURCE" ]]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
while [[ ! -e "${DIR}/jj.filelocation" ]]; do
DIR=$(dirname "${DIR}")
done
echo "${DIR}"
}
export JJ_SOURCE_DIR=$(findJJSource)
if [[ "$1" == "--clean" ]]; then
rm -rf $JJ_SOURCE_DIR/~~tmp/deps
fi
if [[ -e ~/.bun/bin/bun ]]; then
export PATH="~/.bun/bin:${PATH}"
fi
__bunVersionExpect="1.1.34"
__currentBunVersion=$(bun --version || true)
if [[ "$__currentBunVersion" != "${__bunVersionExpect}" ]]; then
rm -rf ~/.bun/bin/bun
curl -fsSL https://bun.sh/install | bash -s "bun-v$__bunVersionExpect"
export PATH="~/.bun/bin:${PATH}"
fi
mkdir -p "$JJ_SOURCE_DIR/~~tmp/deps"
alias jj="$JJ_SOURCE_DIR/jj.sh"
source "$JJ_SOURCE_DIR/bashUtils/index.sh"
# $JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs
# exit 0
eval $($JJ_SOURCE_DIR/helpers/jjEnsure.ts returnProcessEnvs)
# echo $JJ_WORKSPACE_DIR
# jjCliLog jjLog testjjLog a b c s
# jjCliLog jjLogInfo testjjLogInfo
# jjCliLog jjLogHeading testjjLogHeading
source "$JJ_SOURCE_DIR/bashUtils/ensureDependency.sh"
# if [[ ! -e $JJ_SOURCE_DIR/~~tmp/pa ]]; then
# echo "asdadasd"
# fi
# $JJ_SOURCE_DIR/bin/run.ts $@