mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Support .jsonc extension for all JSON files (#1159)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::path::Path;
|
||||
|
||||
use memofs::{DirEntry, IoResultExt, Vfs};
|
||||
use memofs::{DirEntry, Vfs};
|
||||
|
||||
use crate::snapshot::{InstanceContext, InstanceMetadata, InstanceSnapshot};
|
||||
|
||||
@@ -16,26 +16,11 @@ pub fn snapshot_dir(
|
||||
None => return Ok(None),
|
||||
};
|
||||
|
||||
if let Some(mut meta) = dir_meta(vfs, path)? {
|
||||
meta.apply_all(&mut snapshot)?;
|
||||
}
|
||||
DirectoryMetadata::read_and_apply_all(vfs, path, &mut snapshot)?;
|
||||
|
||||
Ok(Some(snapshot))
|
||||
}
|
||||
|
||||
/// Retrieves the meta file that should be applied for this directory, if it
|
||||
/// exists.
|
||||
pub fn dir_meta(vfs: &Vfs, path: &Path) -> anyhow::Result<Option<DirectoryMetadata>> {
|
||||
let meta_path = path.join("init.meta.json");
|
||||
|
||||
if let Some(meta_contents) = vfs.read(&meta_path).with_not_found()? {
|
||||
let metadata = DirectoryMetadata::from_slice(&meta_contents, meta_path)?;
|
||||
Ok(Some(metadata))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
/// Snapshot a directory without applying meta files; useful for if the
|
||||
/// directory's ClassName will change before metadata should be applied. For
|
||||
/// example, this can happen if the directory contains an `init.client.lua`
|
||||
@@ -73,11 +58,8 @@ pub fn snapshot_dir_no_meta(
|
||||
.ok_or_else(|| anyhow::anyhow!("File name was not valid UTF-8: {}", path.display()))?
|
||||
.to_string();
|
||||
|
||||
let meta_path = path.join("init.meta.json");
|
||||
|
||||
let relevant_paths = vec![
|
||||
path.to_path_buf(),
|
||||
meta_path,
|
||||
// TODO: We shouldn't need to know about Lua existing in this
|
||||
// middleware. Should we figure out a way for that function to add
|
||||
// relevant paths to this middleware?
|
||||
|
||||
Reference in New Issue
Block a user