diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-09-29 09:26:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 09:26:25 -0400 |
commit | 5edd102f3f912a53c7bcad3b0fa4feb672ada323 (patch) | |
tree | 2402b64e527bd859f3a2c71d3e96a89992002aa2 /cli/tools/check.rs | |
parent | d43e48c4e96b02289d505cd2558ba85d7d6cb57b (diff) |
refactor(cli): make `CliNpmResolver` a trait (#20732)
This makes `CliNpmResolver` a trait. The terminology used is:
- **managed** - Deno manages the node_modules folder and does an
auto-install (ex. `ManagedCliNpmResolver`)
- **byonm** - "Bring your own node_modules" (ex. `ByonmCliNpmResolver`,
which is in this PR, but unimplemented at the moment)
Part of #18967
Diffstat (limited to 'cli/tools/check.rs')
-rw-r--r-- | cli/tools/check.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/tools/check.rs b/cli/tools/check.rs index a61e3cfe1..0a25518e4 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -44,7 +44,7 @@ pub struct TypeChecker { caches: Arc<Caches>, cli_options: Arc<CliOptions>, node_resolver: Arc<NodeResolver>, - npm_resolver: Arc<CliNpmResolver>, + npm_resolver: Arc<dyn CliNpmResolver>, } impl TypeChecker { @@ -52,7 +52,7 @@ impl TypeChecker { caches: Arc<Caches>, cli_options: Arc<CliOptions>, node_resolver: Arc<NodeResolver>, - npm_resolver: Arc<CliNpmResolver>, + npm_resolver: Arc<dyn CliNpmResolver>, ) -> Self { Self { caches, @@ -74,11 +74,10 @@ impl TypeChecker { // node built-in specifiers use the @types/node package to determine // types, so inject that now (the caller should do this after the lockfile // has been written) - if graph.has_node_specifier { - self - .npm_resolver - .inject_synthetic_types_node_package() - .await?; + if let Some(npm_resolver) = self.npm_resolver.as_managed() { + if graph.has_node_specifier { + npm_resolver.inject_synthetic_types_node_package().await?; + } } log::debug!("Type checking."); |