summaryrefslogtreecommitdiff
path: root/cli/tools/test.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-21 11:46:40 -0400
committerGitHub <noreply@github.com>2023-03-21 15:46:40 +0000
commit2fcf1f14cf29bb68995f652f93a4f6e3cb55c8d7 (patch)
tree04fb972934969cb01a52f3b9b8af0a17134ef5b6 /cli/tools/test.rs
parent0366d6833f25b786e897ce0d6393f692507f0532 (diff)
feat: TypeScript 5.0.2 (except decorators) (#18294)
This upgrades TypeScript to 5.0.2, but does not have ES decorator support because swc does not support that yet.
Diffstat (limited to 'cli/tools/test.rs')
-rw-r--r--cli/tools/test.rs28
1 files changed, 11 insertions, 17 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 0d9637c3d..20788dbd9 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -16,6 +16,7 @@ use crate::util::file_watcher::ResolutionResult;
use crate::util::fs::collect_specifiers;
use crate::util::path::get_extension;
use crate::util::path::is_supported_ext;
+use crate::util::path::mapped_specifier_for_tsc;
use crate::worker::create_main_worker_for_test_or_bench;
use deno_ast::swc::common::comments::CommentKind;
@@ -740,7 +741,6 @@ async fn test_specifier(
}
fn extract_files_from_regex_blocks(
- current_dir: &Path,
specifier: &ModuleSpecifier,
source: &str,
media_type: MediaType,
@@ -800,17 +800,17 @@ fn extract_files_from_regex_blocks(
writeln!(file_source, "{}", text.as_str()).unwrap();
}
- let file_specifier = deno_core::resolve_url_or_path(
- &format!(
- "{}${}-{}{}",
- specifier,
- file_line_index + line_offset + 1,
- file_line_index + line_offset + line_count + 1,
- file_media_type.as_ts_extension(),
- ),
- current_dir,
- )
+ let file_specifier = ModuleSpecifier::parse(&format!(
+ "{}${}-{}",
+ specifier,
+ file_line_index + line_offset + 1,
+ file_line_index + line_offset + line_count + 1,
+ ))
.unwrap();
+ let file_specifier =
+ mapped_specifier_for_tsc(&file_specifier, file_media_type)
+ .map(|s| ModuleSpecifier::parse(&s).unwrap())
+ .unwrap_or(file_specifier);
Some(File {
local: file_specifier.to_file_path().unwrap(),
@@ -827,7 +827,6 @@ fn extract_files_from_regex_blocks(
}
fn extract_files_from_source_comments(
- current_dir: &Path,
specifier: &ModuleSpecifier,
source: Arc<str>,
media_type: MediaType,
@@ -855,7 +854,6 @@ fn extract_files_from_source_comments(
})
.flat_map(|comment| {
extract_files_from_regex_blocks(
- current_dir,
specifier,
&comment.text,
media_type,
@@ -871,7 +869,6 @@ fn extract_files_from_source_comments(
}
fn extract_files_from_fenced_blocks(
- current_dir: &Path,
specifier: &ModuleSpecifier,
source: &str,
media_type: MediaType,
@@ -885,7 +882,6 @@ fn extract_files_from_fenced_blocks(
let lines_regex = Regex::new(r"(?:\# ?)?(.*)")?;
extract_files_from_regex_blocks(
- current_dir,
specifier,
source,
media_type,
@@ -906,14 +902,12 @@ async fn fetch_inline_files(
let inline_files = if file.media_type == MediaType::Unknown {
extract_files_from_fenced_blocks(
- ps.options.initial_cwd(),
&file.specifier,
&file.source,
file.media_type,
)
} else {
extract_files_from_source_comments(
- ps.options.initial_cwd(),
&file.specifier,
file.source,
file.media_type,