mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(add): error when config file contains importMap field (#25115)
The "imports" field has higher precedence than "importMap", so we should error when `deno add` goes to add an `"imports"` field. Closes https://github.com/denoland/deno/issues/24264 Closes https://github.com/denoland/deno/pull/24478
This commit is contained in:
parent
a7c002ae63
commit
37279e0b0a
5 changed files with 22 additions and 0 deletions
|
@ -289,6 +289,17 @@ pub async fn add(
|
|||
_ => bail!("Failed updating config file due to no object."),
|
||||
};
|
||||
|
||||
if obj.get_string("importMap").is_some() {
|
||||
bail!(
|
||||
concat!(
|
||||
"`deno add` is not supported when configuration file contains an \"importMap\" field. ",
|
||||
"Inline the import map into the Deno configuration file.\n",
|
||||
" at {}",
|
||||
),
|
||||
config_specifier
|
||||
);
|
||||
}
|
||||
|
||||
let mut existing_imports = config_file.existing_imports()?;
|
||||
|
||||
let is_npm = config_file.is_npm();
|
||||
|
|
5
tests/specs/add/error_import_map_field/__test__.jsonc
Normal file
5
tests/specs/add/error_import_map_field/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"args": "add jsr:@denotest/add",
|
||||
"output": "add.out",
|
||||
"exitCode": 1
|
||||
}
|
2
tests/specs/add/error_import_map_field/add.out
Normal file
2
tests/specs/add/error_import_map_field/add.out
Normal file
|
@ -0,0 +1,2 @@
|
|||
error: `deno add` is not supported when configuration file contains an "importMap" field. Inline the import map into the Deno configuration file.
|
||||
at file:///[WILDLINE]/deno.json
|
3
tests/specs/add/error_import_map_field/deno.json
Normal file
3
tests/specs/add/error_import_map_field/deno.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"importMap": "./import_map.json"
|
||||
}
|
1
tests/specs/add/error_import_map_field/import_map.json
Normal file
1
tests/specs/add/error_import_map_field/import_map.json
Normal file
|
@ -0,0 +1 @@
|
|||
{}
|
Loading…
Reference in a new issue