mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Implement new oneshot Vfs for CLI commands and enhance JSON5 serialization
- Added `new_oneshot` method to the Vfs struct, providing a backend suitable for one-time operations without file watching. - Updated CLI commands (`fmt_project` and `syncback`) to utilize the new oneshot Vfs, improving error handling during file operations. - Enhanced JSON5 serialization by introducing a custom serializer that directly builds a tree structure, improving performance and maintaining sorted keys. - Improved error logging in JSON serialization to provide more context on failures.
This commit is contained in:
parent
fca802a4e5
commit
5f91a0777a
7 changed files with 3753 additions and 44 deletions
|
|
@ -259,6 +259,28 @@ impl Vfs {
|
|||
Self::new(StdBackend::new())
|
||||
}
|
||||
|
||||
/// Creates a new `Vfs` suitable for one-shot operations like syncback.
|
||||
///
|
||||
/// Unlike `new_default()`, this creates a backend that:
|
||||
/// - Has file watching disabled by default
|
||||
/// - Uses a non-fatal error handler for watcher issues (logs instead of exiting)
|
||||
///
|
||||
/// This is ideal for CLI commands that don't need real-time file watching
|
||||
/// and shouldn't be terminated if the watcher thread encounters issues.
|
||||
pub fn new_oneshot() -> Self {
|
||||
let backend = StdBackend::new_with_error_handler(Box::new(|err| {
|
||||
// Log the error but don't exit - one-shot operations don't need file watching
|
||||
log::debug!(
|
||||
"File watcher issue (non-fatal for one-shot operation): {}",
|
||||
err
|
||||
);
|
||||
true // Stop the watcher thread, but don't exit the process
|
||||
}));
|
||||
let vfs = Self::new(backend);
|
||||
vfs.set_watch_enabled(false);
|
||||
vfs
|
||||
}
|
||||
|
||||
/// Creates a new `Vfs` with the given backend.
|
||||
pub fn new<B: VfsBackend>(backend: B) -> Self {
|
||||
let lock = VfsInner {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue