mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix: update hint for deno add <package>
(#25455)
Follow up to https://github.com/denoland/deno/pull/25430
This commit is contained in:
parent
2c4d99a458
commit
5dc907df87
6 changed files with 27 additions and 22 deletions
|
@ -735,8 +735,8 @@ pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String {
|
||||||
} else {
|
} else {
|
||||||
get_import_prefix_missing_error(error).map(|specifier| {
|
get_import_prefix_missing_error(error).map(|specifier| {
|
||||||
format!(
|
format!(
|
||||||
"If you want to use a JSR or npm package, try running `deno add {}`",
|
"If you want to use a JSR or npm package, try running `deno add jsr:{}` or `deno add npm:{}`",
|
||||||
specifier
|
specifier, specifier
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
@ -881,24 +881,29 @@ fn get_import_prefix_missing_error(error: &ResolutionError) -> Option<&str> {
|
||||||
let mut maybe_specifier = None;
|
let mut maybe_specifier = None;
|
||||||
if let ResolutionError::InvalidSpecifier {
|
if let ResolutionError::InvalidSpecifier {
|
||||||
error: SpecifierError::ImportPrefixMissing { specifier, .. },
|
error: SpecifierError::ImportPrefixMissing { specifier, .. },
|
||||||
..
|
range,
|
||||||
} = error
|
} = error
|
||||||
{
|
{
|
||||||
maybe_specifier = Some(specifier);
|
if range.specifier.scheme() == "file" {
|
||||||
} else if let ResolutionError::ResolverError { error, .. } = error {
|
maybe_specifier = Some(specifier);
|
||||||
match error.as_ref() {
|
}
|
||||||
ResolveError::Specifier(specifier_error) => {
|
} else if let ResolutionError::ResolverError { error, range, .. } = error {
|
||||||
if let SpecifierError::ImportPrefixMissing { specifier, .. } =
|
if range.specifier.scheme() == "file" {
|
||||||
specifier_error
|
match error.as_ref() {
|
||||||
{
|
ResolveError::Specifier(specifier_error) => {
|
||||||
maybe_specifier = Some(specifier);
|
if let SpecifierError::ImportPrefixMissing { specifier, .. } =
|
||||||
|
specifier_error
|
||||||
|
{
|
||||||
|
maybe_specifier = Some(specifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ResolveError::Other(other_error) => {
|
||||||
ResolveError::Other(other_error) => {
|
if let Some(SpecifierError::ImportPrefixMissing {
|
||||||
if let Some(SpecifierError::ImportPrefixMissing { specifier, .. }) =
|
specifier, ..
|
||||||
other_error.downcast_ref::<SpecifierError>()
|
}) = other_error.downcast_ref::<SpecifierError>()
|
||||||
{
|
{
|
||||||
maybe_specifier = Some(specifier);
|
maybe_specifier = Some(specifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
|
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
|
||||||
hint: If you want to use a JSR or npm package, try running `deno add foo`
|
hint: If you want to use a JSR or npm package, try running `deno add jsr:foo` or `deno add npm:foo`
|
||||||
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
|
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
|
[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
|
||||||
hint: If you want to use a JSR or npm package, try running `deno add foo`
|
hint: If you want to use a JSR or npm package, try running `deno add jsr:foo` or `deno add npm:foo`
|
||||||
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
|
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../
|
error: Relative import path "@std/dotenv/load" not prefixed with / or ./ or ../
|
||||||
hint: If you want to use a JSR or npm package, try running `deno add @std/dotenv/load`
|
hint: If you want to use a JSR or npm package, try running `deno add jsr:@std/dotenv/load` or `deno add npm:@std/dotenv/load`
|
||||||
at [WILDCARD]bare_specifier_without_import/main.ts:1:8
|
at [WILDCARD]bare_specifier_without_import/main.ts:1:8
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[WILDCARD]error: Failed resolving types. Relative import path "baz" not prefixed with / or ./ or ../
|
[WILDCARD]error: Failed resolving types. Relative import path "baz" not prefixed with / or ./ or ../
|
||||||
hint: If you want to use a JSR or npm package, try running `deno add baz`
|
hint: If you want to use a JSR or npm package, try running `deno add jsr:baz` or `deno add npm:baz`
|
||||||
at [WILDCARD]/type_definitions/bar.d.ts:[WILDCARD]
|
at [WILDCARD]/type_definitions/bar.d.ts:[WILDCARD]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json'
|
[WILDCARD]Config file found at '[WILDCARD]with_package_json[WILDCARD]with_stop[WILDCARD]some[WILDCARD]nested[WILDCARD]deno.json'
|
||||||
[WILDCARD]
|
[WILDCARD]
|
||||||
error: Relative import path "chalk" not prefixed with / or ./ or ../
|
error: Relative import path "chalk" not prefixed with / or ./ or ../
|
||||||
hint: If you want to use a JSR or npm package, try running `deno add chalk`
|
hint: If you want to use a JSR or npm package, try running `deno add jsr:chalk` or `deno add npm:chalk`
|
||||||
at file:///[WILDCARD]with_package_json/with_stop/some/nested/dir/main.ts:3:19
|
at file:///[WILDCARD]with_package_json/with_stop/some/nested/dir/main.ts:3:19
|
||||||
|
|
Loading…
Reference in a new issue