Skip to content

Commit 8d79b09

Browse files
committed
install script and install instructions
1 parent 6e88b65 commit 8d79b09

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ Rewrite of the popular npm package [http-server](https://github.com/http-party/h
66

77
https://github.com/user-attachments/assets/7b6bbee0-3428-4c9f-80a6-2804ddac6e01
88

9+
## Installation
10+
11+
```bash
12+
npm install -g http-server-rs
13+
```
14+
15+
Or using a binary install script
16+
17+
```bash
18+
eval $(curl -sSf https://raw.githubusercontent.com/alshdavid/http-server-rs/refs/heads/main/install.sh | sh)
19+
```
20+
921
## Usage
1022

1123
```bash

install.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Default to current latest
5+
VERSION="$HTTP_SERVER_RS_VERSION"
6+
if [ "$VERSION" = "" ]; then
7+
VERSION=$(curl --silent "https://api.github.com/repos/alshdavid/http-server-rs/releases/latest" | jq -r '.tag_name')
8+
fi
9+
10+
if [ "$VERSION" = "" ]; then
11+
echo "Unable to fetch version"
12+
exit 1
13+
fi
14+
15+
# Default to home directory
16+
if [ "$OUT_DIR" = "" ]; then
17+
OUT_DIR="$HOME/.local/http-server-rs"
18+
fi
19+
20+
>&2 echo VERSION: $VERSION
21+
>&2 echo OUT_DIR: $OUT_DIR
22+
23+
ARCH=""
24+
case "$(uname -m)" in
25+
x86_64 | x86-64 | x64 | amd64) ARCH="amd64";;
26+
aarch64 | arm64) ARCH="arm64";;
27+
*) ARCH="";;
28+
esac
29+
30+
OS=""
31+
case "$(uname -s)" in
32+
Darwin) OS="macos";;
33+
Linux) OS="linux";;
34+
MINGW64_NT* | Windows_NT) OS="windows";;
35+
*) OS="";;
36+
esac
37+
38+
>&2 echo ARCH: $ARCH
39+
>&2 echo OS: $OS
40+
41+
URL=""
42+
case "$OS-$ARCH" in
43+
linux-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-linux-amd64.tar.gz";;
44+
linux-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-linux-arm64.tar.gz";;
45+
macos-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-macos-amd64.tar.gz";;
46+
macos-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-macos-arm64.tar.gz";;
47+
windows-amd64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-windows-amd64.tar.gz";;
48+
windows-arm64) URL="https://github.com/alshdavid/http-server-rs/releases/download/${VERSION}/http-server-windows-arm64.tar.gz";;
49+
esac
50+
51+
if [ "$URL" = "" ]; then
52+
echo "Cannot find archive"
53+
exit 1
54+
fi
55+
56+
>&2 echo URL: $URL
57+
58+
test -d $OUT_DIR && rm -rf $OUT_DIR
59+
mkdir -p $OUT_DIR
60+
61+
if [ -z "${URL##*.tar.gz}" ]; then
62+
curl -s -L --url $URL | tar -xzf - -C $OUT_DIR
63+
fi
64+
65+
echo "export PATH=\"${OUT_DIR}:\$PATH\""
66+
67+
if [ "$GITHUB_PATH" != "" ]; then
68+
echo "${OUT_DIR}" >> $GITHUB_PATH
69+
fi

0 commit comments

Comments
 (0)