dev: change first arg of LockFile::update to workspace root (#1153)

This commit is contained in:
Myriad-Dreamin 2025-01-11 18:09:26 +08:00 committed by GitHub
parent 6fa10f63fc
commit c0d8f0db1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 8 deletions

View file

@ -21,6 +21,8 @@ use reflexo::path::unix_slash;
pub use anyhow::Result;
const LOCKFILE_PATH: &str = "tinymist.lock";
const LOCK_VERSION: &str = "0.1.0-beta0";
#[derive(Debug, serde::Serialize, serde::Deserialize)]
@ -171,11 +173,10 @@ impl LockFile {
}
}
pub fn update(path: &str, f: impl FnOnce(&mut Self) -> Result<()>) -> Result<()> {
let cwd = Path::new(".").to_owned();
let fs = tinymist_fs::flock::Filesystem::new(cwd);
pub fn update(cwd: &Path, f: impl FnOnce(&mut Self) -> Result<()>) -> Result<()> {
let fs = tinymist_fs::flock::Filesystem::new(cwd.to_owned());
let mut lock_file = fs.open_rw_exclusive_create(path, "project commands")?;
let mut lock_file = fs.open_rw_exclusive_create(LOCKFILE_PATH, "project commands")?;
let mut data = vec![];
lock_file.read_to_end(&mut data)?;

View file

@ -263,11 +263,9 @@ pub struct TaskPreviewArgs {
pub preview_mode: PreviewMode,
}
const LOCKFILE_PATH: &str = "tinymist.lock";
/// Project document commands' main
pub fn project_main(args: DocCommands) -> anyhow::Result<()> {
LockFile::update(LOCKFILE_PATH, |state| {
LockFile::update(Path::new("."), |state| {
match args {
DocCommands::New(args) => {
state.declare(&args);
@ -288,7 +286,7 @@ pub fn project_main(args: DocCommands) -> anyhow::Result<()> {
/// Project task commands' main
pub fn task_main(args: TaskCommands) -> anyhow::Result<()> {
LockFile::update(LOCKFILE_PATH, |state| {
LockFile::update(Path::new("."), |state| {
match args {
TaskCommands::Compile(args) => {
let id = state.declare(&args.declare);