summaryrefslogtreecommitdiff
path: root/test_util/src
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-02-06 15:57:10 -0500
committerGitHub <noreply@github.com>2024-02-06 15:57:10 -0500
commitc6def993e052626be3933de4299bf4b2eb76e48a (patch)
treed377208be4e20bbefb51adb85e546a6f0e65c43b /test_util/src
parenta6b2a4474e50952f28cb933ada0d698fc1055578 (diff)
fix(publish): lazily parse sources (#22301)
Closes #22290
Diffstat (limited to 'test_util/src')
-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)