fix(check): should bust check cache when json module or npm resolution changes (#19941)

A small part of #19928.
This commit is contained in:
David Sherret 2023-07-26 17:23:07 -04:00 committed by GitHub
parent 53e077133f
commit cf16df00d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 223 additions and 58 deletions

View file

@ -10,6 +10,8 @@ use std::sync::Arc;
use anyhow::Context;
use lsp_types::Url;
use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::assertions::assert_wildcard_match;
@ -110,6 +112,10 @@ impl PathRef {
.with_context(|| format!("Could not read file: {}", self))
}
pub fn read_json<TValue: DeserializeOwned>(&self) -> TValue {
serde_json::from_str(&self.read_to_string()).unwrap()
}
pub fn rename(&self, to: impl AsRef<Path>) {
fs::rename(self, self.join(to)).unwrap();
}
@ -118,6 +124,11 @@ impl PathRef {
fs::write(self, text.as_ref()).unwrap();
}
pub fn write_json<TValue: Serialize>(&self, value: &TValue) {
let text = serde_json::to_string_pretty(value).unwrap();
self.write(text);
}
pub fn symlink_dir(
&self,
oldpath: impl AsRef<Path>,