summaryrefslogtreecommitdiff
path: root/test_util/src/servers/registry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test_util/src/servers/registry.rs')
-rw-r--r--test_util/src/servers/registry.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/test_util/src/servers/registry.rs b/test_util/src/servers/registry.rs
index c88045a0d..69728f706 100644
--- a/test_util/src/servers/registry.rs
+++ b/test_util/src/servers/registry.rs
@@ -1,5 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+use crate::testdata_path;
+
use super::run_server;
use super::ServerKind;
use super::ServerOptions;
@@ -59,6 +61,16 @@ async fn registry_server_handler(
return Ok(res);
}
+ // serve the registry package files
+ let mut file_path =
+ testdata_path().to_path_buf().join("jsr").join("registry");
+ file_path.push(&req.uri().path()[1..].replace("%2f", "/"));
+ if let Ok(body) = tokio::fs::read(&file_path).await {
+ return Ok(Response::new(UnsyncBoxBody::new(
+ http_body_util::Full::new(Bytes::from(body)),
+ )));
+ }
+
let empty_body = UnsyncBoxBody::new(Empty::new());
let res = Response::builder()
.status(StatusCode::NOT_FOUND)