diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-09-03 17:00:57 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-03 17:00:57 +1000 |
commit | 5f08d634f73fab21c17cc02f3f3bf8e8b531eee8 (patch) | |
tree | e105697d4ecb23cad491a04af878bc44edfa66a1 /cli/util/path.rs | |
parent | 2533d68cabb5a38be891a9807c452ca802401d46 (diff) |
BREAKING: remove `deno vendor` (#25343)
Diffstat (limited to 'cli/util/path.rs')
-rw-r--r-- | cli/util/path.rs | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/cli/util/path.rs b/cli/util/path.rs index 16378e30b..804b26f65 100644 --- a/cli/util/path.rs +++ b/cli/util/path.rs @@ -145,34 +145,6 @@ pub fn relative_specifier( Some(to_percent_decoded_str(&text)) } -/// Gets a path with the specified file stem suffix. -/// -/// Ex. `file.ts` with suffix `_2` returns `file_2.ts` -pub fn path_with_stem_suffix(path: &Path, suffix: &str) -> PathBuf { - if let Some(file_name) = path.file_name().map(|f| f.to_string_lossy()) { - if let Some(file_stem) = path.file_stem().map(|f| f.to_string_lossy()) { - if let Some(ext) = path.extension().map(|f| f.to_string_lossy()) { - return if file_stem.to_lowercase().ends_with(".d") { - path.with_file_name(format!( - "{}{}.{}.{}", - &file_stem[..file_stem.len() - ".d".len()], - suffix, - // maintain casing - &file_stem[file_stem.len() - "d".len()..], - ext - )) - } else { - path.with_file_name(format!("{file_stem}{suffix}.{ext}")) - }; - } - } - - path.with_file_name(format!("{file_name}{suffix}")) - } else { - path.with_file_name(suffix) - } -} - #[cfg_attr(windows, allow(dead_code))] pub fn relative_path(from: &Path, to: &Path) -> Option<PathBuf> { pathdiff::diff_paths(to, from) @@ -406,46 +378,6 @@ mod test { } #[test] - fn test_path_with_stem_suffix() { - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/"), "_2"), - PathBuf::from("/_2") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test"), "_2"), - PathBuf::from("/test_2") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test.txt"), "_2"), - PathBuf::from("/test_2.txt") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test/subdir"), "_2"), - PathBuf::from("/test/subdir_2") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test/subdir.other.txt"), "_2"), - PathBuf::from("/test/subdir.other_2.txt") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test.d.ts"), "_2"), - PathBuf::from("/test_2.d.ts") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test.D.TS"), "_2"), - PathBuf::from("/test_2.D.TS") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test.d.mts"), "_2"), - PathBuf::from("/test_2.d.mts") - ); - assert_eq!( - path_with_stem_suffix(&PathBuf::from("/test.d.cts"), "_2"), - PathBuf::from("/test_2.d.cts") - ); - } - - #[test] fn test_to_percent_decoded_str() { let str = to_percent_decoded_str("%F0%9F%A6%95"); assert_eq!(str, "🦕"); |