aboutsummaryrefslogtreecommitdiff
path: root/lua/tasks/module/make.lua
blob: 3d176c10cbb5930192eaf850e2c3872928b7cf85 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 `<task>`, calling `Task start make <task>`
  -- will run `make <task>` (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,
  }),
}