diff options
author | Nayeem Rahman <muhammed.9939@gmail.com> | 2020-02-11 09:29:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 10:29:36 +0100 |
commit | 701ce9b3342647cf01cb23c4fc28bc99ce0aa8c1 (patch) | |
tree | e7e36d47453f8f2fe16027ed54d37fee75b153dc /cli/fmt.rs | |
parent | 79b3bc05d6de520f1df73face1744ae3d8be0bb8 (diff) |
refactor: Use PathBuf for paths in flag parsing and whitelists (#3955)
* Use PathBuf for DenoSubcommand::Bundle's out_file
* Use PathBuf for DenoSubcommand::Format's files
* Use PathBuf for DenoSubcommand::Install's dir
* Use PathBuf for read/write whitelists
Diffstat (limited to 'cli/fmt.rs')
-rw-r--r-- | cli/fmt.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cli/fmt.rs b/cli/fmt.rs index 390203f14..f02df560a 100644 --- a/cli/fmt.rs +++ b/cli/fmt.rs @@ -147,11 +147,11 @@ fn format_source_files( ); } -fn get_matching_files(glob_paths: Vec<String>) -> Vec<PathBuf> { +fn get_matching_files(glob_paths: Vec<PathBuf>) -> Vec<PathBuf> { let mut target_files = Vec::with_capacity(128); for path in glob_paths { - let files = glob::glob(&path) + let files = glob::glob(&path.to_str().unwrap()) .expect("Failed to execute glob.") .filter_map(Result::ok); target_files.extend(files); @@ -165,14 +165,14 @@ fn get_matching_files(glob_paths: Vec<String>) -> Vec<PathBuf> { /// First argument supports globs, and if it is `None` /// then the current directory is recursively walked. pub fn format_files( - maybe_files: Option<Vec<String>>, + maybe_files: Option<Vec<PathBuf>>, check: bool, ) -> Result<(), ErrBox> { // TODO: improve glob to look for tsx?/jsx? files only - let glob_paths = maybe_files.unwrap_or_else(|| vec!["**/*".to_string()]); + let glob_paths = maybe_files.unwrap_or_else(|| vec![PathBuf::from("**/*")]); for glob_path in glob_paths.iter() { - if glob_path == "-" { + if glob_path.to_str().unwrap() == "-" { // If the only given path is '-', format stdin. if glob_paths.len() == 1 { format_stdin(check); |