diff options
author | Luca Casonato <hello@lcas.dev> | 2023-08-08 16:28:18 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 16:28:18 -0400 |
commit | 03e963f57831367a39996c7d88bc9875e97d52d7 (patch) | |
tree | 8920cda4906ad9300550679d2492f0023d0beabc /cli | |
parent | f2e30a6f7999fa6ce4ab789266927e3abbb48e3f (diff) |
chore: rename some helpers on the Fs trait (#20097)
Rename some of the helper methods on the Fs trait to be suffixed with
`_sync` / `_async`, in preparation of the introduction of more async
methods for some helpers.
Also adds a `read_text_file_async` helper to complement the renamed
`read_text_file_sync` helper.
Diffstat (limited to 'cli')
-rw-r--r-- | cli/module_loader.rs | 2 | ||||
-rw-r--r-- | cli/node.rs | 8 | ||||
-rw-r--r-- | cli/npm/cache.rs | 4 | ||||
-rw-r--r-- | cli/npm/resolvers/local.rs | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs index b47e2efee..608ee855b 100644 --- a/cli/module_loader.rs +++ b/cli/module_loader.rs @@ -745,7 +745,7 @@ impl NpmModuleLoader { let file_path = specifier.to_file_path().unwrap(); let code = self .fs - .read_to_string(&file_path) + .read_text_file_sync(&file_path) .map_err(AnyError::from) .with_context(|| { if file_path.is_dir() { diff --git a/cli/node.rs b/cli/node.rs index 2a9a84ef9..158627202 100644 --- a/cli/node.rs +++ b/cli/node.rs @@ -91,9 +91,11 @@ impl CjsCodeAnalyzer for CliCjsCodeAnalyzer { ) -> Result<ExtNodeCjsAnalysis, AnyError> { let source = match source { Some(source) => Cow::Borrowed(source), - None => { - Cow::Owned(self.fs.read_to_string(&specifier.to_file_path().unwrap())?) - } + None => Cow::Owned( + self + .fs + .read_text_file_sync(&specifier.to_file_path().unwrap())?, + ), }; let analysis = self.inner_cjs_analysis(specifier, &source)?; Ok(ExtNodeCjsAnalysis { diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index 32989c6a7..c657beef3 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -344,10 +344,10 @@ impl NpmCache { .cache_dir .package_folder_for_name_and_version(package, registry_url); if self.should_use_global_cache_for_package(package) - && self.fs.exists(&package_folder) + && self.fs.exists_sync(&package_folder) // if this file exists, then the package didn't successfully extract // the first time, or another process is currently extracting the zip file - && !self.fs.exists(&package_folder.join(NPM_PACKAGE_SYNC_LOCK_FILENAME)) + && !self.fs.exists_sync(&package_folder.join(NPM_PACKAGE_SYNC_LOCK_FILENAME)) { return Ok(()); } else if self.cache_setting == CacheSetting::Only { diff --git a/cli/npm/resolvers/local.rs b/cli/npm/resolvers/local.rs index 4f8d7b709..6a0065ba8 100644 --- a/cli/npm/resolvers/local.rs +++ b/cli/npm/resolvers/local.rs @@ -181,7 +181,7 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver { Cow::Owned(current_folder.join("node_modules")) }; let sub_dir = join_package_name(&node_modules_folder, name); - if self.fs.is_dir(&sub_dir) { + if self.fs.is_dir_sync(&sub_dir) { // if doing types resolution, only resolve the package if it specifies a types property if mode.is_types() && !name.starts_with("@types/") { let package_json = PackageJson::load_skip_read_permission( @@ -200,7 +200,7 @@ impl NpmPackageFsResolver for LocalNpmPackageResolver { if mode.is_types() && !name.starts_with("@types/") { let sub_dir = join_package_name(&node_modules_folder, &types_package_name(name)); - if self.fs.is_dir(&sub_dir) { + if self.fs.is_dir_sync(&sub_dir) { return Ok(sub_dir); } } |