0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(cli): retain input order of remote specifiers (#11700)

Specifier collection partitions remote specifiers in their own 
group which is appended to the collected specifiers at the 
end of the routine meaning that the input order isn't respected 
for remote specifiers.
This commit is contained in:
Casper Beyer 2021-08-14 16:16:24 +08:00 committed by GitHub
parent 71f79097c6
commit 605f6119e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -181,16 +181,19 @@ pub fn collect_specifiers<P>(
where
P: Fn(&Path) -> bool,
{
let (include_urls, include_paths): (Vec<String>, Vec<String>) =
include.into_iter().partition(|url| {
let url = url.to_lowercase();
url.starts_with("http://") || url.starts_with("https://")
});
let mut prepared = vec![];
let root_path = std::env::current_dir()?;
for path in include_paths {
for path in include {
let lowercase_path = path.to_lowercase();
if lowercase_path.starts_with("http://")
|| lowercase_path.starts_with("https://")
{
let url = ModuleSpecifier::parse(&path)?;
prepared.push(url);
continue;
}
let p = normalize_path(&root_path.join(path));
if p.is_dir() {
let test_files = collect_files(&[p], &[], &predicate).unwrap();
@ -207,11 +210,6 @@ where
}
}
for remote_url in include_urls {
let url = ModuleSpecifier::parse(&remote_url)?;
prepared.push(url);
}
Ok(prepared)
}
@ -433,6 +431,7 @@ mod tests {
.unwrap()
.to_string();
let expected: Vec<ModuleSpecifier> = [
"http://localhost:8080",
&format!("{}/a.ts", root_dir_url),
&format!("{}/b.js", root_dir_url),
&format!("{}/c.tsx", root_dir_url),
@ -441,7 +440,6 @@ mod tests {
&format!("{}/child/f.mjsx", root_dir_url),
&format!("{}/d.jsx", root_dir_url),
&format!("{}/ignore/g.d.ts", root_dir_url),
"http://localhost:8080",
"https://localhost:8080",
]
.iter()