From 636af2850c90f6bf7005a270d95b68bc9718de75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 16 Nov 2020 20:48:50 +0100 Subject: [PATCH] refactor(cli): rename fs module to fs_util (#8380) This commit renames "fs" module in "cli/" to "fs_util". This is purely cosmetic change; there were a few places which aliased "crate::fs" to "deno_fs" which was very confusing with "fs" module in ops. --- cli/disk_cache.rs | 4 ++-- cli/fmt.rs | 2 +- cli/{fs.rs => fs_util.rs} | 0 cli/http_cache.rs | 6 +++--- cli/installer.rs | 2 +- cli/lint.rs | 2 +- cli/main.rs | 10 +++++----- cli/ops/fs.rs | 2 +- cli/permissions.rs | 2 +- cli/test_runner.rs | 6 +++--- cli/tsc_config.rs | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) rename cli/{fs.rs => fs_util.rs} (100%) diff --git a/cli/disk_cache.rs b/cli/disk_cache.rs index 398085cc25..96a4ff41aa 100644 --- a/cli/disk_cache.rs +++ b/cli/disk_cache.rs @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::fs as deno_fs; +use crate::fs_util; use crate::http_cache::url_to_filename; use deno_core::url::{Host, Url}; use std::ffi::OsStr; @@ -145,7 +145,7 @@ impl DiskCache { Some(ref parent) => self.ensure_dir_exists(parent), None => Ok(()), }?; - deno_fs::write_file(&path, data, crate::http_cache::CACHE_PERM) + fs_util::write_file(&path, data, crate::http_cache::CACHE_PERM) .map_err(|e| with_io_context(&e, format!("{:#?}", &path))) } } diff --git a/cli/fmt.rs b/cli/fmt.rs index 9bb4dbc82a..0036436c18 100644 --- a/cli/fmt.rs +++ b/cli/fmt.rs @@ -9,7 +9,7 @@ use crate::colors; use crate::diff::diff; -use crate::fs::{collect_files, is_supported_ext}; +use crate::fs_util::{collect_files, is_supported_ext}; use crate::text_encoding; use deno_core::error::generic_error; use deno_core::error::AnyError; diff --git a/cli/fs.rs b/cli/fs_util.rs similarity index 100% rename from cli/fs.rs rename to cli/fs_util.rs diff --git a/cli/http_cache.rs b/cli/http_cache.rs index 7310c9e921..9cf2adc1a5 100644 --- a/cli/http_cache.rs +++ b/cli/http_cache.rs @@ -4,7 +4,7 @@ /// as defined in RFC 7234 (https://tools.ietf.org/html/rfc7234). /// Currently it's a very simplified version to fulfill Deno needs /// at hand. -use crate::fs as deno_fs; +use crate::fs_util; use crate::http_util::HeadersMap; use deno_core::error::AnyError; use deno_core::serde_json; @@ -87,7 +87,7 @@ impl Metadata { pub fn write(&self, cache_filename: &Path) -> Result<(), AnyError> { let metadata_filename = Self::filename(cache_filename); let json = serde_json::to_string_pretty(self)?; - deno_fs::write_file(&metadata_filename, json, CACHE_PERM)?; + fs_util::write_file(&metadata_filename, json, CACHE_PERM)?; Ok(()) } @@ -161,7 +161,7 @@ impl HttpCache { .expect("Cache filename should have a parent dir"); self.ensure_dir_exists(parent_filename)?; // Cache content - deno_fs::write_file(&cache_filename, content, CACHE_PERM)?; + fs_util::write_file(&cache_filename, content, CACHE_PERM)?; let metadata = Metadata { url: url.to_string(), diff --git a/cli/installer.rs b/cli/installer.rs index dab81bc8d8..e0a99873a1 100644 --- a/cli/installer.rs +++ b/cli/installer.rs @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. use crate::flags::Flags; -use crate::fs::canonicalize_path; +use crate::fs_util::canonicalize_path; use deno_core::error::generic_error; use deno_core::error::AnyError; use deno_core::url::Url; diff --git a/cli/lint.rs b/cli/lint.rs index 1ac680bac3..e319a7be6d 100644 --- a/cli/lint.rs +++ b/cli/lint.rs @@ -10,7 +10,7 @@ use crate::ast; use crate::colors; use crate::fmt::run_parallelized; use crate::fmt_errors; -use crate::fs::{collect_files, is_supported_ext}; +use crate::fs_util::{collect_files, is_supported_ext}; use crate::media_type::MediaType; use deno_core::error::{generic_error, AnyError, JsStackFrame}; use deno_core::serde_json; diff --git a/cli/main.rs b/cli/main.rs index 87e817cf00..11674a8b66 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -22,7 +22,7 @@ mod flags; mod flags_allow_net; mod fmt; mod fmt_errors; -mod fs; +mod fs_util; mod http_cache; mod http_util; mod import_map; @@ -57,7 +57,6 @@ use crate::coverage::CoverageCollector; use crate::coverage::PrettyCoverageReporter; use crate::file_fetcher::File; use crate::file_fetcher::FileFetcher; -use crate::fs as deno_fs; use crate::media_type::MediaType; use crate::permissions::Permissions; use crate::program_state::ProgramState; @@ -381,7 +380,7 @@ async fn bundle_command( if let Some(out_file_) = out_file.as_ref() { let output_bytes = output.as_bytes(); let output_len = output_bytes.len(); - deno_fs::write_file(out_file_, output_bytes, 0o644)?; + fs_util::write_file(out_file_, output_bytes, 0o644)?; info!( "{} {:?} ({})", colors::green("Emit"), @@ -583,8 +582,9 @@ async fn run_with_watch(flags: Flags, script: String) -> Result<(), AnyError> { .collect(); if let Some(import_map) = program_state.flags.import_map_path.clone() { - paths_to_watch - .push(fs::resolve_from_cwd(std::path::Path::new(&import_map)).unwrap()); + paths_to_watch.push( + fs_util::resolve_from_cwd(std::path::Path::new(&import_map)).unwrap(), + ); } // FIXME(bartlomieju): new file watcher is created on after each restart diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs index 37558ec6b8..211404f390 100644 --- a/cli/ops/fs.rs +++ b/cli/ops/fs.rs @@ -2,7 +2,7 @@ // Some deserializer fields are only used on Unix and Windows build fails without it use super::io::std_file_resource; use super::io::{FileMetadata, StreamResource, StreamResourceHolder}; -use crate::fs::canonicalize_path; +use crate::fs_util::canonicalize_path; use crate::permissions::Permissions; use deno_core::error::custom_error; use deno_core::error::type_error; diff --git a/cli/permissions.rs b/cli/permissions.rs index 204176ad3b..cc3ce82423 100644 --- a/cli/permissions.rs +++ b/cli/permissions.rs @@ -2,7 +2,7 @@ use crate::colors; use crate::flags::Flags; -use crate::fs::resolve_from_cwd; +use crate::fs_util::resolve_from_cwd; use deno_core::error::custom_error; use deno_core::error::uri_error; use deno_core::error::AnyError; diff --git a/cli/test_runner.rs b/cli/test_runner.rs index 265b514c1a..cd8a394c50 100644 --- a/cli/test_runner.rs +++ b/cli/test_runner.rs @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::fs as deno_fs; +use crate::fs_util; use crate::installer::is_remote_url; use deno_core::error::AnyError; use deno_core::serde_json::json; @@ -42,10 +42,10 @@ pub fn prepare_test_modules_urls( let mut prepared = vec![]; for path in include_paths { - let p = deno_fs::normalize_path(&root_path.join(path)); + let p = fs_util::normalize_path(&root_path.join(path)); if p.is_dir() { let test_files = - crate::fs::collect_files(vec![p], vec![], is_supported).unwrap(); + crate::fs_util::collect_files(vec![p], vec![], is_supported).unwrap(); let test_files_as_urls = test_files .iter() .map(|f| Url::from_file_path(f).unwrap()) diff --git a/cli/tsc_config.rs b/cli/tsc_config.rs index 92332cca67..5012e03a96 100644 --- a/cli/tsc_config.rs +++ b/cli/tsc_config.rs @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::fs::canonicalize_path; +use crate::fs_util::canonicalize_path; use deno_core::error::AnyError; use deno_core::serde_json; use deno_core::serde_json::json;