fix(build): allow build command to override plugin's build and option to disable warning

This commit is contained in:
Folke Lemaitre 2023-06-30 21:19:30 +02:00
parent de0a911ad9
commit 189371c8d8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 25 additions and 8 deletions

View file

@ -1,5 +1,6 @@
local Util = require("lazy.util")
local Loader = require("lazy.core.loader")
local Config = require("lazy.core.config")
---@type table<string, LazyTaskDef>
local M = {}
@ -32,14 +33,17 @@ M.build = {
local build_file = get_build_file(self.plugin)
if build_file then
if builders then
Util.warn(
("Plugin **%s** provides its own build script.\nPlease remove the `build` option from the plugin's spec"):format(
self.plugin.name
if Config.options.build.warn_on_override then
Util.warn(
("Plugin **%s** provides its own build script, but you also defined a `build` command.\nThe `build.lua` file will not be used"):format(
self.plugin.name
)
)
)
end
builders = function()
Loader.source(build_file)
end
else
builders = function()
Loader.source(build_file)
end
end
end
if builders then