diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-13 22:44:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 02:44:16 +0000 |
commit | 9aa20b3ba758765863a4c1055097fda399efcfc3 (patch) | |
tree | 08ee8de378feb8037bbf609912939718620eaf08 /cli/tools/bundle.rs | |
parent | 48ede89f1f192df28cc74822d7bb79b0b4bd0957 (diff) |
refactor: --watch commands use deno_core::resolve_url_or_path (#18172)
This commit changes various CLI subcommands that have support for
the "--watch" flag to use initial current working directory when
resolving "main module".
This is part of migration towards explicitly passing current working
directory to "deno_core::resolve_url_or_path" API.
As a side effect this makes "deno <subcommand> --watch" more aligned to
user expectations, where calling "Deno.chdir()" during program doesn't
break watcher.
Towards landing https://github.com/denoland/deno/pull/15454
Diffstat (limited to 'cli/tools/bundle.rs')
-rw-r--r-- | cli/tools/bundle.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/cli/tools/bundle.rs b/cli/tools/bundle.rs index c1d4befb1..5a42f834e 100644 --- a/cli/tools/bundle.rs +++ b/cli/tools/bundle.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use deno_core::error::AnyError; use deno_core::futures::FutureExt; -use deno_core::resolve_url_or_path_deprecated; +use deno_core::resolve_url_or_path; use deno_graph::Module; use deno_runtime::colors; @@ -35,16 +35,17 @@ pub async fn bundle( "Use alternative bundlers like \"deno_emit\", \"esbuild\" or \"rollup\" instead." ); + let module_specifier = + resolve_url_or_path(&bundle_flags.source_file, cli_options.initial_cwd())?; + let resolver = |_| { let cli_options = cli_options.clone(); - let source_file1 = &bundle_flags.source_file; - let source_file2 = &bundle_flags.source_file; + let module_specifier = &module_specifier; async move { - let module_specifier = resolve_url_or_path_deprecated(source_file1)?; - log::debug!(">>>>> bundle START"); let ps = ProcState::from_options(cli_options).await?; - let graph = create_graph_and_maybe_check(module_specifier, &ps).await?; + let graph = + create_graph_and_maybe_check(module_specifier.clone(), &ps).await?; let mut paths_to_watch: Vec<PathBuf> = graph .specifiers() @@ -74,7 +75,7 @@ pub async fn bundle( result: Ok((ps, graph)), }, Err(e) => ResolutionResult::Restart { - paths_to_watch: vec![PathBuf::from(source_file2)], + paths_to_watch: vec![module_specifier.to_file_path().unwrap()], result: Err(e), }, }) |