uninstall
1 #!/usr/bin/env bash 2 set -eu 3 4 # adapted from https://github.com/johannes-wolf/cetz/blob/35c0868378cea5ad323cc0d9c2f76de8ed9ba5bd/scripts/package 5 # licensed under Apache License 2.0 6 7 . "$(dirname "${BASH_SOURCE[0]}")/setup" 8 9 if (( $# < 1 )) || [[ "${1:-}" == "help" ]]; then 10 echo "uninstall TARGET" 11 echo "" 12 echo "Removes the package installed into a directory named '<name>/<version>'" 13 echo "at TARGET. If TARGET is set to @local or @preview, the local Typst package" 14 echo "directory will be used so that the package gets installed for local use." 15 echo "The name and version are read from 'typst.toml' in the project root." 16 echo "" 17 echo "Local package prefix: $DATA_DIR/typst/package/local" 18 echo "Local preview package prefix: $DATA_DIR/typst/package/preview" 19 exit 1 20 fi 21 22 TARGET="$(resolve-target "${1:?Missing target path, @local or @preview}")" 23 echo "Install dir: $TARGET" 24 25 TARGET="${TARGET:?}/${PKG_PREFIX:?}/${VERSION:?}" 26 echo "Package to uninstall: $TARGET" 27 if [[ ! -e "${TARGET:?}" ]]; then 28 echo "Package was not found." 29 elif rm -r "${TARGET:?}" 2>/dev/null; then 30 echo "Successfully removed." 31 else 32 echo "Removal failed." 33 fi