<# diffweb installer — Windows (PowerShell 5.1+ / 7+). powershell -c "irm https://diffweb.pages.dev/install.ps1|iex" & ([scriptblock]::Create((irm https://diffweb.pages.dev/install.ps1))) -Uninstall #> param([switch] $Uninstall) $ErrorActionPreference = 'Stop' # Release tarball from `npm run build:version`. Update this once it is hosted. $Url = if ($env:DIFFWEB_URL) { $env:DIFFWEB_URL } else { 'https://raw.githubusercontent.com/acharyarupak391/diffweb/main/bin/diffweb.tar.gz' } $Dir = if ($env:DIFFWEB_HOME) { $env:DIFFWEB_HOME } else { Join-Path $env:LOCALAPPDATA 'diffweb' } $Bin = if ($env:DIFFWEB_BIN) { $env:DIFFWEB_BIN } else { Join-Path $Dir 'bin' } if ($Uninstall -or $env:DIFFWEB_UNINSTALL -eq '1') { if (Test-Path (Join-Path $Bin 'diffweb.cmd')) { Remove-Item (Join-Path $Bin 'diffweb.cmd') -Force } if (Test-Path $Dir) { Remove-Item $Dir -Recurse -Force } Write-Host " diffweb removed" -ForegroundColor Green exit 0 } if (-not (Get-Command node -ErrorAction SilentlyContinue)) { throw "Node.js 16+ is required. Install it from https://nodejs.org and re-run." } if (-not (Get-Command tar -ErrorAction SilentlyContinue)) { throw "tar is required (built in to Windows 10 1803+)." } Write-Host "`n diffweb installer`n" -ForegroundColor DarkGray Write-Host " downloading $Url" $tmp = Join-Path $env:TEMP 'diffweb.tar.gz' $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri $Url -OutFile $tmp -UseBasicParsing New-Item -ItemType Directory -Path $Dir -Force | Out-Null tar -xzf $tmp -C $Dir --strip-components=1 Remove-Item $tmp -Force $entry = Join-Path $Dir 'server.js' if (-not (Test-Path $entry)) { throw "the archive is missing server.js" } New-Item -ItemType Directory -Path $Bin -Force | Out-Null Set-Content -Path (Join-Path $Bin 'diffweb.cmd') -Encoding ASCII -Value "@echo off`r`nnode `"$entry`" %*" $version = (& node $entry --version) Write-Host " diffweb $version installed to $Dir" -ForegroundColor Green Write-Host " launcher $Bin\diffweb.cmd" -ForegroundColor Green $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (($userPath -split ';') -notcontains $Bin) { [Environment]::SetEnvironmentVariable('Path', "$userPath;$Bin", 'User') $env:Path = "$env:Path;$Bin" Write-Host " added $Bin to your PATH — open a new terminal to pick it up" -ForegroundColor Yellow } Write-Host "`n Try it: diffweb old.txt new.txt`n" -ForegroundColor Cyan