Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(add): exact version should not have range ^ specifier #26302

Merged
merged 4 commits into from
Oct 16, 2024
Merged
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
14 changes: 10 additions & 4 deletions cli/tools/registry/pm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,11 @@ async fn find_package_and_select_version_for_req(
});
};
let range_symbol = if req.version_req.version_text().starts_with('~') {
'~'
"~"
} else if req.version_req.version_text() == nv.version.to_string() {
""
} else {
'^'
"^"
};
Ok(PackageAndVersion::Selected(SelectedPackage {
import_name: add_package_req.alias,
Expand All @@ -637,11 +639,15 @@ async fn find_package_and_select_version_for_req(
package_req: req,
});
};

let range_symbol = if req.version_req.version_text().starts_with('~') {
'~'
"~"
} else if req.version_req.version_text() == nv.version.to_string() {
""
} else {
'^'
"^"
};

Ok(PackageAndVersion::Selected(SelectedPackage {
import_name: add_package_req.alias,
package_name: npm_prefixed_name,
Expand Down
35 changes: 35 additions & 0 deletions tests/specs/add/exact_version/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"tempDir": true,
"tests": {
"npm": {
"steps": [
{
"args": "add npm:@denotest/esm-basic@1.0.0",
"output": "npm_add.out"
},
{
"args": [
"eval",
"console.log(Deno.readTextFileSync('deno.json').trim())"
],
"output": "npm_deno.json.out"
}
]
},
"jsr": {
"steps": [
{
"args": "add jsr:@denotest/add@1.0.0",
"output": "jsr_add.out"
},
{
"args": [
"eval",
"console.log(Deno.readTextFileSync('deno.json').trim())"
],
"output": "jsr_deno.json.out"
}
]
}
}
}
1 change: 1 addition & 0 deletions tests/specs/add/exact_version/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions tests/specs/add/exact_version/jsr_add.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add jsr:@denotest/add@1.0.0
Download http://127.0.0.1:4250/@denotest/add/1.0.0/mod.ts
5 changes: 5 additions & 0 deletions tests/specs/add/exact_version/jsr_deno.json.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"@denotest/add": "jsr:@denotest/add@1.0.0"
}
}
3 changes: 3 additions & 0 deletions tests/specs/add/exact_version/npm_add.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add npm:@denotest/esm-basic@1.0.0
Download http://localhost:4260/@denotest/esm-basic
Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
5 changes: 5 additions & 0 deletions tests/specs/add/exact_version/npm_deno.json.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0"
}
}