Skip to content

Commit

Permalink
Handle new binary names in archives.
Browse files Browse the repository at this point in the history
elves/elvish@deec3c0
changed the binary names in archives to simply "elvish" or "elvish.exe". Handle
that case.
  • Loading branch information
xiaq committed Feb 26, 2024
1 parent 636d357 commit f12d001
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu, macos, windows]
elvish-version: [0.18.0, HEAD]
elvish-version: [0.20.1, HEAD]
runs-on: ${{ matrix.os }}-latest
steps:
- uses: elves/setup-elvish@main
Expand All @@ -20,3 +20,7 @@ jobs:
shell: elvish {0}
run: |
echo This is Elvish $version
- name: Run with Elvish with explicit version
shell: elvish-${{ matrix.elvish-version }} {0}
run: |
echo This is Elvish $version
16 changes: 14 additions & 2 deletions main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ async function main() {
const arch = archMap[process.arch] || process.arch;
const platform = platformMap[process.platform] || process.platform;
const urlBase = `https://dl.elv.sh/${platform}-${arch}/elvish-${version}`;
// https://github.com/elves/elvish/commit/deec3c06b2a7d4ba9c4ac01edc90bdca7844c143
// change the binary name within the archive to be just "elvish" or
// "elvish.exe"; before that the name was elvish-${version} or
// elvish-${version}.exe. Handle both cases.
if (platform === 'windows') {
await run('pwsh', '-c',
`
Expand All @@ -17,14 +21,22 @@ async function main() {
Invoke-RestMethod -Uri '${urlBase}.zip' -OutFile elvish.zip
Expand-Archive elvish.zip -DestinationPath .
rm elvish.zip
New-Item -ItemType SymbolicLink -Path elvish.exe -Target elvish-${version}.exe
if (Test-Path elvish.exe -PathType leaf) {
New-Item -ItemType SymbolicLink -Path elvish-${version}.exe -Target elvish.exe
} else {
New-Item -ItemType SymbolicLink -Path elvish.exe -Target elvish-${version}.exe
}
`);
} else {
await run('sh', '-c',
`
cd /usr/local/bin
curl -o- ${urlBase}.tar.gz | tar xz
ln -sf elvish-${version} elvish
if test -f elvish; then
ln -sf elvish elvish-${version}
else
ln -sf elvish-${version} elvish
fi
`);
}
}
Expand Down

0 comments on commit f12d001

Please sign in to comment.