mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
refactor(cli): migrate run and cache to new infrastructure (#7996)
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
This commit is contained in:
parent
9fa59f0ca8
commit
7e2c7fb6c5
48 changed files with 1181 additions and 1299 deletions
|
@ -579,6 +579,29 @@ fn map_js_like_extension(path: &Path, default: MediaType) -> MediaType {
|
|||
None => default,
|
||||
Some("jsx") => MediaType::JSX,
|
||||
Some("tsx") => MediaType::TSX,
|
||||
// Because DTS files do not have a separate media type, or a unique
|
||||
// extension, we have to "guess" at those things that we consider that
|
||||
// look like TypeScript, and end with `.d.ts` are DTS files.
|
||||
Some("ts") => {
|
||||
if default == MediaType::TypeScript {
|
||||
match path.file_stem() {
|
||||
None => default,
|
||||
Some(os_str) => {
|
||||
if let Some(file_stem) = os_str.to_str() {
|
||||
if file_stem.ends_with(".d") {
|
||||
MediaType::Dts
|
||||
} else {
|
||||
default
|
||||
}
|
||||
} else {
|
||||
default
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
default
|
||||
}
|
||||
}
|
||||
Some(_) => default,
|
||||
},
|
||||
}
|
||||
|
@ -1564,7 +1587,7 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
map_content_type(Path::new("foo/bar.d.ts"), None).0,
|
||||
MediaType::TypeScript
|
||||
MediaType::Dts
|
||||
);
|
||||
assert_eq!(
|
||||
map_content_type(Path::new("foo/bar.js"), None).0,
|
||||
|
@ -1741,6 +1764,26 @@ mod tests {
|
|||
.0,
|
||||
MediaType::JSX
|
||||
);
|
||||
assert_eq!(
|
||||
map_content_type(
|
||||
Path::new("foo/bar.d.ts"),
|
||||
Some("application/x-javascript")
|
||||
)
|
||||
.0,
|
||||
MediaType::JavaScript
|
||||
);
|
||||
assert_eq!(
|
||||
map_content_type(Path::new("foo/bar.d.ts"), Some("text/plain")).0,
|
||||
MediaType::Dts
|
||||
);
|
||||
assert_eq!(
|
||||
map_content_type(
|
||||
Path::new("foo/bar.d.ts"),
|
||||
Some("video/vnd.dlna.mpeg-tts"),
|
||||
)
|
||||
.0,
|
||||
MediaType::Dts
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue