From 605f6119e96fb67edad53c426f2f65793e0b1faa Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Sat, 14 Aug 2021 16:16:24 +0800 Subject: 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. --- cli/fs_util.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'cli') 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

( where P: Fn(&Path) -> bool, { - let (include_urls, include_paths): (Vec, Vec) = - 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 = [ + "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() -- cgit v1.2.3