Skip to content

Commit 1530c8b

Browse files
committed
Add iex-compatible branch parsing
Remove the param block and rename DefaultBranch to $defaultBranch. Add argument parsing for iex-compatible invocations (e.g. `iex -dev main`, `iex main`, or no args) by inspecting $args and selecting the branch accordingly, then log the chosen branch. Simplify branch handling and build the GitHub ZIP download URL using the resolved branch. Small cleanup and reordering of steps to accommodate the new parsing logic.
1 parent 6423d94 commit 1530c8b

1 file changed

Lines changed: 25 additions & 13 deletions

File tree

bootstrap.ps1

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
# irm https://catswords.blob.core.windows.net/welsonjs/bootstrap.ps1 | iex
88
# irm https://catswords.blob.core.windows.net/welsonjs/bootstrap.ps1 | iex -dev main
99
# irm https://catswords.blob.core.windows.net/welsonjs/bootstrap.ps1 | iex -dev dev
10+
# irm https://catswords.blob.core.windows.net/welsonjs/bootstrap.ps1 | iex main
1011
#
1112
# Central default branch configuration for this install script.
1213
# Update this value if the repository's default branch changes.
13-
$DefaultBranch = "master"
14-
15-
param(
16-
# Branch to install from; defaults to the repository's configured primary branch.
17-
[string]$dev = $DefaultBranch
18-
)
14+
$defaultBranch = "master"
1915

2016
$ErrorActionPreference = "Stop"
2117

@@ -32,6 +28,27 @@ function Write-Err($msg) {
3228
}
3329

3430
try {
31+
# Step 0: Parse arguments (iex-compatible)
32+
# Supports:
33+
# iex -dev main
34+
# iex main
35+
# iex
36+
$branch = $defaultBranch
37+
38+
for ($i = 0; $i -lt $args.Count; $i++) {
39+
$arg = $args[$i]
40+
41+
if ($arg -eq "-dev" -and ($i + 1) -lt $args.Count) {
42+
$branch = $args[$i + 1]
43+
break
44+
}
45+
elseif ($arg -notmatch "^-") {
46+
$branch = $arg
47+
}
48+
}
49+
50+
Write-Step "Using branch: $branch"
51+
3552
# Step 1: Create a temporary working directory using a UUID
3653
Write-Step "Creating temporary workspace..."
3754

@@ -45,12 +62,7 @@ try {
4562
$repo = "gnh1201/welsonjs"
4663
$zipPath = Join-Path $tempDir "package.zip"
4764

48-
# Step 2: Determine branch (default: master)
49-
$branch = $dev
50-
51-
Write-Step "Using branch: $branch"
52-
53-
# GitHub branch ZIP URL
65+
# Step 2: Build download URL
5466
$downloadUrl = "https://github.com/$repo/archive/refs/heads/$branch.zip"
5567

5668
Write-Ok "Download URL: $downloadUrl"
@@ -102,4 +114,4 @@ try {
102114
catch {
103115
Write-Err $_
104116
exit 1
105-
}
117+
}

0 commit comments

Comments
 (0)