summaryrefslogtreecommitdiff
path: root/cli/util
diff options
context:
space:
mode:
Diffstat (limited to 'cli/util')
-rw-r--r--cli/util/fs.rs12
-rw-r--r--cli/util/import_map.rs5
2 files changed, 13 insertions, 4 deletions
diff --git a/cli/util/fs.rs b/cli/util/fs.rs
index bab36b31e..c81686f95 100644
--- a/cli/util/fs.rs
+++ b/cli/util/fs.rs
@@ -361,8 +361,7 @@ pub fn collect_specifiers(
if path.is_dir() {
result.push(PathOrPattern::Path(path));
} else if !files.exclude.matches_path(&path) {
- let url = ModuleSpecifier::from_file_path(&path)
- .map_err(|_| anyhow!("Invalid file path '{}'", path.display()))?;
+ let url = specifier_from_file_path(&path)?;
prepared.push(url);
}
}
@@ -385,7 +384,7 @@ pub fn collect_specifiers(
.collect_file_patterns(files)?;
let mut collected_files_as_urls = collected_files
.iter()
- .map(|f| ModuleSpecifier::from_file_path(f).unwrap())
+ .map(|f| specifier_from_file_path(f).unwrap())
.collect::<Vec<ModuleSpecifier>>();
collected_files_as_urls.sort();
@@ -703,6 +702,13 @@ impl LaxSingleProcessFsFlag {
}
}
+pub fn specifier_from_file_path(
+ path: &Path,
+) -> Result<ModuleSpecifier, AnyError> {
+ ModuleSpecifier::from_file_path(path)
+ .map_err(|_| anyhow!("Invalid file path '{}'", path.display()))
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/cli/util/import_map.rs b/cli/util/import_map.rs
index 2656389b8..b8b8b9a1a 100644
--- a/cli/util/import_map.rs
+++ b/cli/util/import_map.rs
@@ -4,6 +4,7 @@ use std::collections::HashSet;
use deno_ast::ParsedSource;
use deno_ast::SourceRange;
+use deno_ast::SourceTextInfo;
use deno_core::serde_json;
use deno_core::ModuleSpecifier;
use deno_graph::DefaultModuleAnalyzer;
@@ -72,6 +73,7 @@ fn values_to_set<'a>(
pub enum ImportMapUnfurlDiagnostic {
UnanalyzableDynamicImport {
specifier: ModuleSpecifier,
+ text_info: SourceTextInfo,
range: SourceRange,
},
}
@@ -150,6 +152,7 @@ impl<'a> ImportMapUnfurler<'a> {
ImportMapUnfurlDiagnostic::UnanalyzableDynamicImport {
specifier: url.to_owned(),
range: SourceRange::new(start_pos, end_pos),
+ text_info: parsed_source.text_info().clone(),
},
);
}
@@ -295,7 +298,7 @@ mod tests {
fn parse_ast(specifier: &Url, source_code: &str) -> ParsedSource {
let media_type = MediaType::from_specifier(specifier);
deno_ast::parse_module(deno_ast::ParseParams {
- specifier: specifier.to_string(),
+ specifier: specifier.clone(),
media_type,
capture_tokens: false,
maybe_syntax: None,