mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Enhance path handling for init files in ApiService
- Updated logic in `api.rs` to correctly handle cases where existing paths are init files, ensuring that children are placed in the appropriate directory. - Improved clarity in comments to explain the handling of init files and their relationship to directory structure, contributing to better maintainability of the code.
This commit is contained in:
parent
bc77b26f07
commit
f2f5e01a87
1 changed files with 9 additions and 0 deletions
|
|
@ -869,6 +869,15 @@ impl ApiService {
|
|||
if !added.children.is_empty() {
|
||||
let children_dir = if existing_path.is_dir() {
|
||||
existing_path.to_path_buf()
|
||||
} else if existing_path
|
||||
.file_name()
|
||||
.and_then(|n| n.to_str())
|
||||
.map_or(false, |n| n.starts_with("init."))
|
||||
{
|
||||
// existing_path is an init file (e.g., DirFoo/init.luau).
|
||||
// The instance is already in directory format -- children go
|
||||
// into the same directory that contains the init file.
|
||||
existing_path.parent().unwrap_or(existing_path).to_path_buf()
|
||||
} else {
|
||||
// Standalone scripts cannot have children in Rojo's file format.
|
||||
// We need to convert from standalone (e.g., MyScript.server.luau)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue