refactor(ext/node): allow injecting NodeFs from CLI (#18829)

This allows providing a `NodeFs` as part of the `WorkerOptions`.
This commit is contained in:
David Sherret 2023-04-24 19:44:35 -04:00 committed by GitHub
parent bb74e75a04
commit aa286fdecb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1631 additions and 1687 deletions

View file

@ -4,7 +4,6 @@ use crate::args::CliOptions;
use crate::args::Flags;
use crate::args::TaskFlags;
use crate::colors;
use crate::node::CliNodeResolver;
use crate::npm::CliNpmResolver;
use crate::proc_state::ProcState;
use crate::util::fs::canonicalize_path;
@ -13,7 +12,7 @@ use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::futures;
use deno_core::futures::future::LocalBoxFuture;
use deno_runtime::deno_node::RealFs;
use deno_runtime::deno_node::NodeResolver;
use deno_semver::npm::NpmPackageNv;
use deno_task_shell::ExecuteResult;
use deno_task_shell::ShellCommand;
@ -236,13 +235,12 @@ impl ShellCommand for NpmPackageBinCommand {
fn resolve_npm_commands(
npm_resolver: &CliNpmResolver,
node_resolver: &CliNodeResolver,
node_resolver: &NodeResolver,
) -> Result<HashMap<String, Rc<dyn ShellCommand>>, AnyError> {
let mut result = HashMap::new();
let snapshot = npm_resolver.snapshot();
for id in snapshot.top_level_packages() {
let bin_commands =
node_resolver.resolve_binary_commands::<RealFs>(&id.nv)?;
let bin_commands = node_resolver.resolve_binary_commands(&id.nv)?;
for bin_command in bin_commands {
result.insert(
bin_command.to_string(),