Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LeeCheneler/e0b79a43874b0d1e6f57c4fb2916ed54 to your computer and use it in GitHub Desktop.
Save LeeCheneler/e0b79a43874b0d1e6f57c4fb2916ed54 to your computer and use it in GitHub Desktop.
monorepo scripts
#!/bin/bash
# get directory of script
CONFIGS_DIR="$(git rev-parse --show-toplevel)/configs"
# get command to execute and the args to forward args
COMMAND="$1"
shift
ARGS="$@"
# switch through commands
case "$COMMAND" in
"build")
pnpm esbuild --sourcemap --target=es2020 --outdir=dist --bundle --packages=external --platform=node --format=esm --banner:js='"use client";' $ARGS
;;
"dev")
pnpm esbuild --sourcemap --target=es2020 --outdir=dist --bundle --packages=external --platform=node --format=esm --banner:js='"use client";' --watch=true $ARGS
;;
"test")
pnpm jest --config "$CONFIGS_DIR/jest.config.js" $ARGS
;;
"typecheck")
pnpm tsc -p "$CONFIGS_DIR/tsconfig.json" --noEmit $ARGS
;;
*)
cat << EOF
usage: Usage: ops-scripts [command] [args?]
commands:
build Build the library, args are passed directly to esbuild
dev Build the library in watch mode, args are passed directly to esbuild
test Run tests, args are passed directly to jest
typecheck Run typecheck, args are passed directly to tsc
EOF
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment