This commit is contained in:
EwDev 2026-10-03 14:19:27 +00:00 • committed by GitHub
commit 0bffb88bc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 61 additions and 26 deletions

View file

@ -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])

View file

@ -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>

View file

@ -0,0 +1,9 @@
{
"name": "init_from_path",
"tree": {
"$className": "Folder",
"folder": {
"$path": "folder/init.luau"
}
}
}

View file

@ -0,0 +1 @@
-- ignore_me.luau

View file

@ -0,0 +1 @@
-- init.luau

View file

@ -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::*;

View file

@ -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),
}
}

View file

@ -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) {