mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(lsp): update diagnostics on npm install (#25352)
This commit is contained in:
parent
0e0a5c24ea
commit
84dc375b2d
2 changed files with 53 additions and 4 deletions
|
@ -1697,9 +1697,14 @@ impl ConfigTree {
|
|||
}
|
||||
|
||||
pub fn is_watched_file(&self, specifier: &ModuleSpecifier) -> bool {
|
||||
if specifier.path().ends_with("/deno.json")
|
||||
|| specifier.path().ends_with("/deno.jsonc")
|
||||
|| specifier.path().ends_with("/package.json")
|
||||
let path = specifier.path();
|
||||
if path.ends_with("/deno.json")
|
||||
|| path.ends_with("/deno.jsonc")
|
||||
|| path.ends_with("/package.json")
|
||||
|| path.ends_with("/node_modules/.package-lock.json")
|
||||
|| path.ends_with("/node_modules/.yarn-integrity.json")
|
||||
|| path.ends_with("/node_modules/.modules.yaml")
|
||||
|| path.ends_with("/node_modules/.deno/.setup-cache.bin")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -14767,7 +14767,6 @@ fn lsp_byonm() {
|
|||
"@denotest/esm-basic": "*",
|
||||
},
|
||||
}));
|
||||
context.run_npm("install");
|
||||
let mut client = context.new_lsp_command().build();
|
||||
client.initialize_default();
|
||||
let diagnostics = client.did_open(json!({
|
||||
|
@ -14781,6 +14780,51 @@ fn lsp_byonm() {
|
|||
"#,
|
||||
},
|
||||
}));
|
||||
assert_eq!(
|
||||
json!(diagnostics.all()),
|
||||
json!([
|
||||
{
|
||||
"range": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"character": 15,
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"character": 26,
|
||||
},
|
||||
},
|
||||
"severity": 1,
|
||||
"code": "resolver-error",
|
||||
"source": "deno",
|
||||
"message": "Could not find a matching package for 'npm:chalk' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.",
|
||||
},
|
||||
{
|
||||
"range": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"character": 15,
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"character": 36,
|
||||
},
|
||||
},
|
||||
"severity": 1,
|
||||
"code": "resolver-error",
|
||||
"source": "deno",
|
||||
"message": "Could not resolve \"@denotest/esm-basic\", but found it in a package.json. Deno expects the node_modules/ directory to be up to date. Did you forget to run `deno install`?",
|
||||
},
|
||||
])
|
||||
);
|
||||
context.run_npm("install");
|
||||
client.did_change_watched_files(json!({
|
||||
"changes": [{
|
||||
"uri": temp_dir.url().join("node_modules/.package-lock.json").unwrap(),
|
||||
"type": 1,
|
||||
}],
|
||||
}));
|
||||
let diagnostics = client.read_diagnostics();
|
||||
assert_eq!(
|
||||
json!(diagnostics.all()),
|
||||
json!([
|
||||
|
|
Loading…
Reference in a new issue