Created
July 29, 2022 10:02
-
-
Save bitdivine/e997e8333d374c0b5add5aaeb85acb66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
: Move to the repo root, assuming this is installed at ./scripts/dfx-start-join | |
cd "$(dirname "$(realpath "$0")")/.." | |
help_text() { | |
cat <<-EOF | |
Joins an existing locally running dfx server. | |
Polyfill for: `dfx start --join` | |
Flags: | |
--help | |
Prints this help text and exits. | |
EOF | |
} | |
while (($# > 0)); do | |
arg="$1" | |
shift 1 | |
case "$arg" in | |
--help) | |
help_text | |
exit 0 | |
;; | |
*) | |
cat <<-EOF >&2 | |
ERROR: Unrecognised argument: '$arg' | |
Please use --help for usage. | |
EOF | |
exit 1 | |
;; | |
esac | |
done | |
: Find the locally running dfx server | |
# TODO: Handle the case where there is none running. | |
# OS-dependent: | |
# - tested on Linux | |
# - TODO: test on osx | |
DFX_SERVER_DIR="$(realpath "/proc/$(pgrep -n icx-proxy)/cwd")" | |
: Link | |
[[ "$(realpath .dfx)" == "$(realpath "$DFX_SERVER_DIR")/.dfx" ]] || { | |
ln -s "$(realpath "$DFX_SERVER_DIR")/.dfx" .dfx | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment