diff options
author | Ćukasz Czerniawski <33061335+lczerniawski@users.noreply.github.com> | 2024-03-15 00:53:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-14 23:53:46 +0000 |
commit | 5403e4f06b2bb9da60c67b7c1909f4d412c20307 (patch) | |
tree | feffd2a905c6b01d0bf2599cd6c72d04286636f1 /cli/util | |
parent | 85116226b3b5faae0aa85ce5d053487e82dcc824 (diff) |
chore(cli): move away from PathBuf in clap (#22036)
Diffstat (limited to 'cli/util')
-rw-r--r-- | cli/util/path.rs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/cli/util/path.rs b/cli/util/path.rs index fed74cb06..b64fde6b9 100644 --- a/cli/util/path.rs +++ b/cli/util/path.rs @@ -163,20 +163,6 @@ pub fn relative_specifier( }) } -/// This function checks if input path has trailing slash or not. If input path -/// has trailing slash it will return true else it will return false. -pub fn path_has_trailing_slash(path: &Path) -> bool { - if let Some(path_str) = path.to_str() { - if cfg!(windows) { - path_str.ends_with('\\') - } else { - path_str.ends_with('/') - } - } else { - false - } -} - /// Gets a path with the specified file stem suffix. /// /// Ex. `file.ts` with suffix `_2` returns `file_2.ts` @@ -433,31 +419,6 @@ mod test { } #[test] - fn test_path_has_trailing_slash() { - #[cfg(not(windows))] - { - run_test("/Users/johndoe/Desktop/deno-project/target/", true); - run_test(r"/Users/johndoe/deno-project/target//", true); - run_test("/Users/johndoe/Desktop/deno-project", false); - run_test(r"/Users/johndoe/deno-project\", false); - } - - #[cfg(windows)] - { - run_test(r"C:\test\deno-project\", true); - run_test(r"C:\test\deno-project\\", true); - run_test(r"C:\test\file.txt", false); - run_test(r"C:\test\file.txt/", false); - } - - fn run_test(path_str: &str, expected: bool) { - let path = Path::new(path_str); - let result = path_has_trailing_slash(path); - assert_eq!(result, expected); - } - } - - #[test] fn test_path_with_stem_suffix() { assert_eq!( path_with_stem_suffix(&PathBuf::from("/"), "_2"), |