diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-13 21:12:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 01:12:09 +0000 |
commit | 48ede89f1f192df28cc74822d7bb79b0b4bd0957 (patch) | |
tree | d6dd65cf03152fb0253aba551f7ed016e3b7b09f /cli/tools/doc.rs | |
parent | c4771356f27b250e7fdbcede0de5682982720455 (diff) |
refactor(core): resolve_url_or_path and resolve_url_or_path_deprecated (#18170)
This commit changes current "deno_core::resolve_url_or_path" API to
"resolve_url_or_path_deprecated" and adds new "resolve_url_or_path"
API that requires to explicitly pass the directory from which paths
should be resolved to.
Some of the call sites were updated to use the new API, the reminder
of them will be updated in a follow up PR.
Towards landing https://github.com/denoland/deno/pull/15454
Diffstat (limited to 'cli/tools/doc.rs')
-rw-r--r-- | cli/tools/doc.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 2ee80f6b7..38553e9ff 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -12,7 +12,6 @@ use crate::proc_state::ProcState; use crate::tsc::get_types_declaration_file_text; use deno_ast::MediaType; use deno_core::anyhow::bail; -use deno_core::anyhow::Context; use deno_core::error::AnyError; use deno_core::resolve_path; use deno_core::resolve_url_or_path; @@ -62,12 +61,13 @@ pub async fn print_docs( doc_parser.parse_module(&source_file_specifier)?.definitions } DocSourceFileFlag::Path(source_file) => { - let cwd = std::env::current_dir().context("Unable to get CWD")?; - let module_specifier = resolve_url_or_path(&source_file)?; + let module_specifier = + resolve_url_or_path(&source_file, ps.options.initial_cwd())?; // If the root module has external types, the module graph won't redirect it, // so instead create a dummy file which exports everything from the actual file being documented. - let root_specifier = resolve_path("./$deno$doc.ts", &cwd).unwrap(); + let root_specifier = + resolve_path("./$deno$doc.ts", ps.options.initial_cwd()).unwrap(); let root = File { local: PathBuf::from("./$deno$doc.ts"), maybe_types: None, |