Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,59 @@ jobs:
- name: Check version
run: deno -V | grep -q "deno 1\.43\.1"

test-version-file-dvm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

# dvm records the version as `key=value`, possibly not on the first line
- name: Write a dvm-style .dvmrc
run: |
printf 'registry_binary=https://dl.deno.land\ndeno_version=1.43.1\n' \
> "$RUNNER_TEMP/.dvmrc"

- name: Setup Deno
uses: ./
with:
deno-version-file: ${{ runner.temp }}/.dvmrc

- name: Check version
run: deno -V | grep -q "deno 1\.43\.1"

test-version-file-rejects-url:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

# A version file is repo content, so it must never be able to choose what
# gets downloaded. dvm's registry key is not read, and a URL is not a
# valid version: both are rejected before any download happens.
- name: Write version files that try to point elsewhere
run: |
printf 'registry_binary=https://example.invalid\n' \
> "$RUNNER_TEMP/.dvmrc-registry"
printf 'deno_version=https://example.invalid/deno.zip\n' \
> "$RUNNER_TEMP/.dvmrc-url"

- name: Setup Deno with a registry-only .dvmrc
id: registry-only
continue-on-error: true
uses: ./
with:
deno-version-file: ${{ runner.temp }}/.dvmrc-registry

- name: Setup Deno with a URL as the version
id: url-version
continue-on-error: true
uses: ./
with:
deno-version-file: ${{ runner.temp }}/.dvmrc-url

- name: Both must have been rejected
run: |
test "${{ steps.registry-only.outcome }}" = failure
test "${{ steps.url-version.outcome }}" = failure

test-binary-name:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
3 changes: 2 additions & 1 deletion dist/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19331,7 +19331,8 @@ function getDenoVersionFromFile(versionFilePath) {
if (!fs$3.existsSync(versionFilePath)) throw new Error(`The specified node version file at: ${versionFilePath} does not exist`);
const contents = fs$3.readFileSync(versionFilePath, "utf8");
const denoVersionInToolVersions = contents.match(/^deno\s+v?(?<version>[^\s]+)$/m);
return denoVersionInToolVersions?.groups?.version || contents.trim();
const denoVersionInDvmrc = contents.match(/^[^\S\n]*deno_version[^\S\n]*=[^\S\n]*v?(?<version>[^\s]+)[^\S\n]*$/m);
return denoVersionInToolVersions?.groups?.version || denoVersionInDvmrc?.groups?.version || contents.trim();
}
function resolveVersion({ range, kind }) {
if (kind === "canary") return resolveCanary(range);
Expand Down
Loading
Loading