-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhyperlink.sh
More file actions
executable file
·51 lines (45 loc) · 1.27 KB
/
hyperlink.sh
File metadata and controls
executable file
·51 lines (45 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Wrapper script for hyperlink CLI tool
# First tries to run hyperlink directly if available on PATH
# Falls back to npx on supported platforms, otherwise shows cargo install instructions
is_supported_platform() {
local arch=$(uname -m)
local os=$(uname -s)
case "$os" in
Darwin)
# MacOS (both Intel and ARM)
return 0
;;
CYGWIN*|MINGW*|MSYS*)
# Windows
return 0
;;
Linux)
# Only x86 Linux is supported by npm package
if [[ "$arch" == "x86_64" ]]; then
return 0
else
return 1
fi
;;
*)
return 1
;;
esac
}
main() {
# First, try to use hyperlink if it's available on PATH
if command -v hyperlink >/dev/null 2>&1; then
exec hyperlink "$@"
fi
# If not available, check if we can use npx
if is_supported_platform; then
exec npx @untitaker/hyperlink "$@"
else
echo "Error: hyperlink not found and npm package not available for this platform."
echo "Please install it with: cargo install --locked hyperlink"
echo "Make sure you have Rust/Cargo installed first."
exit 1
fi
}
main "$@"