fetch ¶
function fetch(owner: string, repo: string, tag: string, asset?: string): Promise<Package>
Constructs a new Package object from the GitHub Release, with a defined fetchInfo property.
When using this function, the asset gets saved to a local cache, which makes future fetch calls for the same asset resolve right away. Zip files are extracted using a modified version of the zzlib library.
The function returns a Promise object for convenience. Use the fetchAsync function if you want to wait for the result instead.
Fetching from a large repository
When the asset field is undefined, the source code of the release will be downloaded.
Because Rostruct uses a Lua zip library to extract .zip files, there may be performance issues when extracting large files.
Prefer to upload an asset for files you want to run in Rostruct.
Parameters¶
owner: string- The owner of the repositoryrepo: string- The name of the repositorytag: string- The tag version to downloadasset?: string | undefined- Optional asset to download; If not specified, it downloads the source files
Example usage¶
This example loads Roact v1.4.0:
local Roact = Rostruct.fetch("Roblox", "roact", "v1.4.0")
:andThen(function(package)
if package.fetchInfo.updated then
print("First time installation!")
end
package:build("src/", { Name = "Roact" })
return package:require(package.tree.Roact)
end)
:catch(function(err)
warn("Error loading Roact:", err)
end)
:expect()
local package = Rostruct.fetchAsync("Roblox", "roact", "v1.4.0")
if package.fetchInfo.updated then
print("First time installation!")
end
package:build("src/", { Name = "Roact" })
local Roact = package:requireAsync(package.tree.Roact)