This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Tasks
SquidDev edited this page Dec 12, 2014
·
5 revisions
The simplest way to define a task is through the Tasks:Task
functions
Tasks:Task "compile"(function()
print("Compiling now...")
end)
You can define dependencies:
Tasks:Task "test"({"compile"}, function()
print("Running tests")
end)
You can also chains functions together:
Task:Task "test"(function()
print("Running tests")
end)
:Depends("compile")
:Description("Compile and run tests")
You can also use the Tasks:AddTask
function. This also supports chaining:
TaskRunner:AddTask("test", {"compile"}, function()
print("running tests")
end):Description("Compile and run tests")
Some tasks have predefined functions. These normally follow the pattern Tasks::TypeName(name, options, taskDependencies)
Clean removes a directory/file from the filesystem. It is worth noting that the directory is global, so you must use fs.combine
Tasks:Clean("clean", fs.combine(CurrentDirectory, "build"))
Combines a dependency tree into one file
local sources = Dependencies(CurrentDirectory)
sources:Main "Thing.lua"
:Depends "Another"
sources:Main "Another.lua"
:Name "Another"
Tasks:Combine("combine", sources, "build.lua", {"clean"})
You can read more on dependencies here.
There are multiple ways to minify files:
This allows you to define a task that can minify any file based on a wildcard.
-- All these arguments are optional
-- We define a task called _minify that reads in anything called
-- *.lua and produces a *.min.lua file
Tasks:MinifyAll("_minify", "wild:*.lua", "wild:*.min.lua")
-- So now we can do
Tasks:AddTask "minify"
:Requires(File "Result.min.lua")
:Description("Produces a minified version of the code")
-- And it runs any task needed to create Result.min.lua and minifies it
This is much more simple, but much less flexible:
Tasks:Minify("minify", "Result.lua", "Result.min.lua", {"combine"})