mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-04 10:18:16 +00:00
dev: change first arg of LockFile::update
to workspace root (#1153)
This commit is contained in:
parent
6fa10f63fc
commit
c0d8f0db1c
2 changed files with 7 additions and 8 deletions
|
@ -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)?;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue