mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Merge b2a767318d into 95262a02e9
This commit is contained in:
commit
0bffb88bc9
8 changed files with 61 additions and 26 deletions
|
|
@ -31,6 +31,10 @@ Making a new release? Simply add the new header with the version and date undern
|
|||
|
||||
## Unreleased
|
||||
|
||||
* Fixed a bug where `$path` in an instance description couldn't reference an init script directly (i.e init.luau, init.sever.luau, etc). ([#1285])
|
||||
|
||||
[#1285]: https://github.com/rojo-rbx/rojo/pull/1285
|
||||
|
||||
## [7.7.1] (October 1st, 2026)
|
||||
|
||||
* Fixed `$path` values that point outside the project folder failing to match `syncRule`s on Windows, which broke `rojo sourcemap` with a "could not be turned into a Roblox Instance" error. ([#1290])
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
source: tests/tests/build.rs
|
||||
expression: contents
|
||||
---
|
||||
<roblox version="4">
|
||||
<Item class="Folder" referent="0">
|
||||
<Properties>
|
||||
<string name="Name">init_from_path</string>
|
||||
</Properties>
|
||||
<Item class="ModuleScript" referent="1">
|
||||
<Properties>
|
||||
<string name="Name">folder</string>
|
||||
<string name="Source"><![CDATA[-- init.luau
|
||||
]]></string>
|
||||
</Properties>
|
||||
</Item>
|
||||
</Item>
|
||||
</roblox>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "init_from_path",
|
||||
"tree": {
|
||||
"$className": "Folder",
|
||||
"folder": {
|
||||
"$path": "folder/init.luau"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
-- ignore_me.luau
|
||||
1
rojo-test/build-tests/init_from_path/folder/init.luau
Normal file
1
rojo-test/build-tests/init_from_path/folder/init.luau
Normal file
|
|
@ -0,0 +1 @@
|
|||
-- init.luau
|
||||
|
|
@ -51,7 +51,7 @@ pub fn snapshot_dir_no_meta(
|
|||
for entry in vfs.read_dir(path)? {
|
||||
let entry = entry?;
|
||||
|
||||
if !passes_filter_rules(&entry) {
|
||||
if !passes_filter_rules(&entry) || is_init_file(entry.path()).unwrap() {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -221,6 +221,21 @@ pub fn syncback_dir_no_meta<'sync>(
|
|||
})
|
||||
}
|
||||
|
||||
fn is_init_file(path: &Path) -> anyhow::Result<bool> {
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.with_context(|| format!("file name of {} is invalid", path.display()))?;
|
||||
|
||||
match file_name {
|
||||
"init.server.luau" | "init.server.lua" | "init.client.luau" | "init.client.lua"
|
||||
| "init.plugin.luau" | "init.plugin.lua" | "init.luau" | "init.lua" | "init.csv" => {
|
||||
Ok(true)
|
||||
}
|
||||
_ => Ok(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -72,32 +72,18 @@ pub fn snapshot_from_vfs(
|
|||
None => return Ok(None),
|
||||
};
|
||||
|
||||
if meta.is_dir() {
|
||||
let (middleware, dir_name, init_path) = get_dir_middleware(vfs, path)?;
|
||||
// TODO: Support user defined init paths
|
||||
// If and when we do, make sure to go support it in
|
||||
// `Project::set_file_name`, as right now it special-cases
|
||||
// `default.project.json` as an `init` path.
|
||||
match middleware {
|
||||
Middleware::Dir => middleware.snapshot(context, vfs, path, dir_name),
|
||||
_ => middleware.snapshot(context, vfs, &init_path, dir_name),
|
||||
}
|
||||
} else {
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.with_context(|| format!("file name of {} is invalid", path.display()))?;
|
||||
if !meta.is_dir() {
|
||||
return snapshot_from_path(context, vfs, path);
|
||||
}
|
||||
|
||||
// TODO: Is this even necessary anymore?
|
||||
match file_name {
|
||||
"init.server.luau" | "init.server.lua" | "init.client.luau" | "init.client.lua"
|
||||
| "init.plugin.luau" | "init.plugin.lua" | "init.luau" | "init.lua" | "init.csv" => {
|
||||
return Ok(None)
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
snapshot_from_path(context, vfs, path)
|
||||
let (middleware, dir_name, init_path) = get_dir_middleware(vfs, path)?;
|
||||
// TODO: Support user defined init paths
|
||||
// If and when we do, make sure to go support it in
|
||||
// `Project::set_file_name`, as right now it special-cases
|
||||
// `default.project.json` as an `init` path.
|
||||
match middleware {
|
||||
Middleware::Dir => middleware.snapshot(context, vfs, path, dir_name),
|
||||
_ => middleware.snapshot(context, vfs, &init_path, dir_name),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ gen_build_tests! {
|
|||
no_name_project,
|
||||
no_name_top_level_project,
|
||||
plugin_init,
|
||||
init_from_path,
|
||||
}
|
||||
|
||||
fn run_build_test(test_name: &str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue