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

Fixes https://github.com/denoland/deno/issues/26299
This commit is contained in:
Marvin Hagemeister 2024-10-16 18:34:33 +02:00 committed by GitHub
parent 06778e4e9b
commit e515f3dd0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 61 additions and 4 deletions

View File

@ -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,
@ -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,

View File

@ -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"
}
]
}
}
}

View File

@ -0,0 +1 @@
{}

View File

@ -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

View File

@ -0,0 +1,5 @@
{
"imports": {
"@denotest/add": "jsr:@denotest/add@1.0.0"
}
}

View File

@ -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

View File

@ -0,0 +1,5 @@
{
"imports": {
"@denotest/esm-basic": "npm:@denotest/esm-basic@1.0.0"
}
}