mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-21 05:06:29 +00:00
Untangle route terminology a bit
This commit is contained in:
@@ -169,38 +169,34 @@ function Plugin:stopPolling()
|
||||
return Promise.resolve(true)
|
||||
end
|
||||
|
||||
function Plugin:_pull(api, project, routes)
|
||||
return api:read(routes)
|
||||
function Plugin:_pull(api, project, fileRoutes)
|
||||
return api:read(fileRoutes)
|
||||
:andThen(function(items)
|
||||
for index = 1, #routes do
|
||||
local itemRoute = routes[index]
|
||||
local partitionName = itemRoute[1]
|
||||
for index = 1, #fileRoutes do
|
||||
local fileRoute = fileRoutes[index]
|
||||
local partitionName = fileRoute[1]
|
||||
local partition = project.partitions[partitionName]
|
||||
local item = items[index]
|
||||
|
||||
local partitionRoute = collectMatch(partition.target, "[^.]+")
|
||||
local partitionTargetRbxRoute = collectMatch(partition.target, "[^.]+")
|
||||
|
||||
-- If the item route's length was 1, we need to rename the instance to
|
||||
-- line up with the partition's root object name.
|
||||
--
|
||||
-- This is a HACK!
|
||||
if #itemRoute == 1 then
|
||||
if item then
|
||||
local objectName = partition.target:match("[^.]+$")
|
||||
item.Name = objectName
|
||||
end
|
||||
if item ~= nil and #fileRoute == 1 then
|
||||
local objectName = partition.target:match("[^.]+$")
|
||||
item.Name = objectName
|
||||
end
|
||||
|
||||
local fullRoute = {}
|
||||
for _, piece in ipairs(partitionRoute) do
|
||||
table.insert(fullRoute, piece)
|
||||
local itemRbxRoute = {}
|
||||
for _, piece in ipairs(partitionTargetRbxRoute) do
|
||||
table.insert(itemRbxRoute, piece)
|
||||
end
|
||||
|
||||
for i = 2, #itemRoute do
|
||||
table.insert(fullRoute, itemRoute[i])
|
||||
for i = 2, #fileRoute do
|
||||
table.insert(itemRbxRoute, fileRoute[i])
|
||||
end
|
||||
|
||||
self._reconciler:reconcileRoute(fullRoute, item, itemRoute)
|
||||
self._reconciler:reconcileRoute(itemRbxRoute, item, fileRoute)
|
||||
end
|
||||
end)
|
||||
end
|
||||
@@ -283,13 +279,13 @@ function Plugin:syncIn()
|
||||
return Promise.reject(info)
|
||||
end
|
||||
|
||||
local routes = {}
|
||||
local fileRoutes = {}
|
||||
|
||||
for name in pairs(info.project.partitions) do
|
||||
table.insert(routes, {name})
|
||||
table.insert(fileRoutes, {name})
|
||||
end
|
||||
|
||||
local pullSuccess, pullResult = self:_pull(api, info.project, routes):await()
|
||||
local pullSuccess, pullResult = self:_pull(api, info.project, fileRoutes):await()
|
||||
|
||||
self._syncInProgress = false
|
||||
|
||||
|
||||
@@ -202,12 +202,12 @@ function Reconciler:reconcile(rbx, item)
|
||||
return rbx
|
||||
end
|
||||
|
||||
function Reconciler:reconcileRoute(route, item, itemRoute)
|
||||
function Reconciler:reconcileRoute(rbxRoute, item, fileRoute)
|
||||
local parent
|
||||
local rbx = game
|
||||
|
||||
for i = 1, #route do
|
||||
local piece = route[i]
|
||||
for i = 1, #rbxRoute do
|
||||
local piece = rbxRoute[i]
|
||||
|
||||
local child = rbx:FindFirstChild(piece)
|
||||
|
||||
@@ -223,7 +223,7 @@ function Reconciler:reconcileRoute(route, item, itemRoute)
|
||||
end
|
||||
|
||||
-- We don't want to create a folder if we're reaching our target item!
|
||||
if child == nil and i ~= #route then
|
||||
if child == nil and i ~= #rbxRoute then
|
||||
child = Instance.new("Folder")
|
||||
child.Parent = rbx
|
||||
child.Name = piece
|
||||
@@ -235,7 +235,7 @@ function Reconciler:reconcileRoute(route, item, itemRoute)
|
||||
|
||||
-- Let's check the route map!
|
||||
if rbx == nil then
|
||||
rbx = self._routeMap:get(itemRoute)
|
||||
rbx = self._routeMap:get(fileRoute)
|
||||
end
|
||||
|
||||
rbx = self:reconcile(rbx, item)
|
||||
|
||||
Reference in New Issue
Block a user