diff --git a/CHANGES.md b/CHANGES.md index 44af3d5a..c5eab9f2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,7 +1,8 @@ # Rojo Change Log ## Current Master -* *No changes* +* Tightened `init` file rules to only match script files + * Previously, Rojo would sometimes pick up the wrong file when syncing ## 0.2.2 * Plugin only release diff --git a/README.md b/README.md index b4f34711..dd0ac9ab 100644 --- a/README.md +++ b/README.md @@ -110,17 +110,17 @@ Creation of Roblox instances follows a simple set of rules. The first rule that | `*.lua` | `ModuleScript` | `Source` will contain the file's contents | | `*` | `StringValue` | `Value` will contain the file's contents | -Any folders on the filesystem will turn into `Folder` objects unless they contain a file named `init` with any extension. Following the convention of Lua, those objects will instead be whatever the `init` file would turn into. +Any folders on the filesystem will turn into `Folder` objects unless they contain a file named `init.lua`, `init.server.lua`, or `init.client.lua`. Following the convention of Lua, those objects will instead be whatever the `init` file would turn into. For example, this file tree: * my-game - * init.lua + * init.client.lua * foo.lua Will turn into this tree in Roblox: -* `my-game` (`ModuleScript` with source from `my-game/init.lua`) +* `my-game` (`LocalScript` with source from `my-game/init.client.lua`) * `foo` (`ModuleScript` with source from `my-game/foo.lua`) ## Inspiration diff --git a/plugin/src/Config.lua b/plugin/src/Config.lua index 10ff8824..80db250d 100644 --- a/plugin/src/Config.lua +++ b/plugin/src/Config.lua @@ -1,4 +1,4 @@ return { pollingRate = 0.3, - version = "0.2.2", + version = "DEV", } diff --git a/plugin/src/Reconciler.lua b/plugin/src/Reconciler.lua index 1aa97a6f..38176aa9 100644 --- a/plugin/src/Reconciler.lua +++ b/plugin/src/Reconciler.lua @@ -1,13 +1,27 @@ local Reconciler = {} +--[[ + The set of file names that should pass as init files + These files usurp their parents. +]] +local initNames = { + ["init.lua"] = true, + ["init.server.lua"] = true, + ["init.client.lua"] = true, +} + local function isInit(item, itemFileName) if item and item.type == "dir" then return end - return not not itemFileName:find("^init%.") + return initNames[itemFileName] or false end +--[[ + Determines if the given VFS item has an init file. Yields information about + the file. +]] local function findInit(item) if item.type ~= "dir" then return nil, nil @@ -22,6 +36,12 @@ local function findInit(item) return nil, nil end +--[[ + Given a VFS item, returns a Name and ClassName for a corresponding Roblox + instance. + + Doesn't take into account init files. +]] local function itemToName(item, fileName) if item and item.type == "dir" then return fileName, "Folder" @@ -40,6 +60,10 @@ local function itemToName(item, fileName) end end +--[[ + Given a VFS item, assigns all relevant values (except Name!) to a Roblox + instance. +]] local function setValues(rbx, item, fileName) local _, className = itemToName(item, fileName) @@ -79,6 +103,9 @@ function Reconciler._reifyShallow(item, fileName) end end +--[[ + Construct a new Roblox instance tree that corresponds to the given VFS item. +]] function Reconciler._reify(item, fileName, parent) local rbx = Reconciler._reifyShallow(item, fileName)