diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-08-14 16:16:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-14 10:16:24 +0200 |
commit | 605f6119e96fb67edad53c426f2f65793e0b1faa (patch) | |
tree | d286964d78e1de609e49cac8584948f1c7ff2d4c | |
parent | 71f79097c69958ba94e8600430394bbb21fa90f3 (diff) |
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.
-rw-r--r-- | cli/fs_util.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/cli/fs_util.rs b/cli/fs_util.rs index 6fa841376..d88e466c5 100644 --- a/cli/fs_util.rs +++ b/cli/fs_util.rs @@ -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() |