summaryrefslogtreecommitdiff
path: root/ext/node/analyze.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-08-08 16:28:18 -0400
committerGitHub <noreply@github.com>2023-08-08 16:28:18 -0400
commit03e963f57831367a39996c7d88bc9875e97d52d7 (patch)
tree8920cda4906ad9300550679d2492f0023d0beabc /ext/node/analyze.rs
parentf2e30a6f7999fa6ce4ab789266927e3abbb48e3f (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 'ext/node/analyze.rs')
-rw-r--r--ext/node/analyze.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/node/analyze.rs b/ext/node/analyze.rs
index 902fe9f44..3648756f0 100644
--- a/ext/node/analyze.rs
+++ b/ext/node/analyze.rs
@@ -205,7 +205,7 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
)?;
let package_json_path = module_dir.join("package.json");
- if self.fs.exists(&package_json_path) {
+ if self.fs.exists_sync(&package_json_path) {
let package_json = PackageJson::load(
&*self.fs,
&*self.npm_resolver,
@@ -229,10 +229,10 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
// old school
if package_subpath != "." {
let d = module_dir.join(package_subpath);
- if self.fs.is_dir(&d) {
+ if self.fs.is_dir_sync(&d) {
// subdir might have a package.json that specifies the entrypoint
let package_json_path = d.join("package.json");
- if self.fs.exists(&package_json_path) {
+ if self.fs.exists_sync(&package_json_path) {
let package_json = PackageJson::load(
&*self.fs,
&*self.npm_resolver,
@@ -262,13 +262,13 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
referrer: &Path,
) -> Result<PathBuf, AnyError> {
let p = p.clean();
- if self.fs.exists(&p) {
+ if self.fs.exists_sync(&p) {
let file_name = p.file_name().unwrap();
let p_js =
p.with_file_name(format!("{}.js", file_name.to_str().unwrap()));
- if self.fs.is_file(&p_js) {
+ if self.fs.is_file_sync(&p_js) {
return Ok(p_js);
- } else if self.fs.is_dir(&p) {
+ } else if self.fs.is_dir_sync(&p) {
return Ok(p.join("index.js"));
} else {
return Ok(p);
@@ -276,7 +276,7 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
} else if let Some(file_name) = p.file_name() {
let p_js =
p.with_file_name(format!("{}.js", file_name.to_str().unwrap()));
- if self.fs.is_file(&p_js) {
+ if self.fs.is_file_sync(&p_js) {
return Ok(p_js);
}
}