#!/usr/bin/env bash

# This script is intended to be run after `snap-build`.
#
# It expects the `zed.snap` built by `snap-build` to be in the current
# directory.
#
# This will uninstall the current `zed` snap, replacing it with a snap
# that directly uses the `snap/unpacked` directory.

set -euxo pipefail

# Rerun as root
[ "$UID" -eq 0 ] || exec sudo bash -e "$0" "$@"

snap remove zed || true
mkdir -p snap
rm -rf snap/unpacked
unsquashfs -dest snap/unpacked zed.snap
snap try --classic snap/unpacked
