1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 09:10:40 -05:00

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.
This commit is contained in:
Bartek Iwańczuk 2020-11-16 20:48:50 +01:00 committed by GitHub
parent 8ab20a4582
commit 636af2850c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 19 additions and 19 deletions

View file

@ -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)))
}
}

View file

@ -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;

View file

@ -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(),

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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())

View file

@ -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;