From f2cbe8f4f5fbfc73ae8eb08521cd0080f536e626 Mon Sep 17 00:00:00 2001 From: undyamon <148129121+undyamon@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:02:35 +0100 Subject: Add make module (#18) --- lua/tasks/module/make.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lua/tasks/module/make.lua (limited to 'lua/tasks') diff --git a/lua/tasks/module/make.lua b/lua/tasks/module/make.lua new file mode 100644 index 0000000..3d176c1 --- /dev/null +++ b/lua/tasks/module/make.lua @@ -0,0 +1,22 @@ +local Path = require('plenary.path') + +return { + params = { 'cmd' }, + condition = function() return Path:new('Makefile'):exists() end, + + -- This module supports dynamic tasks by using the `__index` metamethod. + -- By default, for any string ``, calling `Task start make ` + -- will run `make ` (i.e., dynamic tasks are mapped to make targets). + -- This behavior can be customized by overriding the task 'args' parameters + -- in the `default_params` provided on setup. + tasks = setmetatable({}, { + __index = function(_, target) + return function(module_config, _) + return { + cmd = module_config.cmd, + args = module_config.args and module_config.args[target] or { target }, + } + end + end, + }), +} -- cgit v1.2.3