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): Support dist tags in deno add #24960

Merged
merged 1 commit into from
Aug 8, 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
4 changes: 4 additions & 0 deletions cli/npm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ impl NpmFetchResolver {
let maybe_get_nv = || async {
let name = req.name.clone();
let package_info = self.package_info(&name).await?;
if let Some(dist_tag) = req.version_req.tag() {
let version = package_info.dist_tags.get(dist_tag)?.clone();
return Some(PackageNv { name, version });
}
// Find the first matching version of the package.
let mut versions = package_info.versions.keys().collect::<Vec<_>>();
versions.sort();
Expand Down
9 changes: 9 additions & 0 deletions tests/specs/add/dist_tag/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tempDir": true,
"steps": [
{
"args": "add npm:ajv@latest",
"output": "Add npm:[email protected]\n"
}
]
}
Empty file.
12 changes: 12 additions & 0 deletions tests/specs/install/future_install_add_dist_tag/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"tempDir": true,
"steps": [
{
"envs": {
"DENO_FUTURE": "1"
},
"args": "install npm:ajv@latest",
"output": "install.out"
}
]
}
Empty file.
15 changes: 15 additions & 0 deletions tests/specs/install/future_install_add_dist_tag/install.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Add npm:[email protected]
[UNORDERED_START]
Download http://localhost:4260/ajv
Download http://localhost:4260/fast-deep-equal
Download http://localhost:4260/json-schema-traverse
Download http://localhost:4260/require-from-string
Download http://localhost:4260/uri-js
Download http://localhost:4260/punycode
Download http://localhost:4260/ajv/ajv-8.11.0.tgz
Download http://localhost:4260/fast-deep-equal/fast-deep-equal-3.1.3.tgz
Download http://localhost:4260/uri-js/uri-js-4.4.1.tgz
Download http://localhost:4260/json-schema-traverse/json-schema-traverse-1.0.0.tgz
Download http://localhost:4260/require-from-string/require-from-string-2.0.2.tgz
Download http://localhost:4260/punycode/punycode-2.1.1.tgz
[UNORDERED_END]