forked from rojo-rbx/rojo
Uses Stylua to format all existing Lua files, and adds a CI check in `lint` to pin this improvement. Excludes formatting dependencies, of course.
31 lines
651 B
Lua
31 lines
651 B
Lua
local Packages = script.Parent.Parent.Packages
|
|
local Fmt = require(Packages.Fmt)
|
|
|
|
local Config = require(script.Parent.Config)
|
|
|
|
local invariant
|
|
|
|
if Config.isDevBuild then
|
|
function invariant(message, ...)
|
|
message = Fmt.fmt(message, ...)
|
|
|
|
error("Invariant violation: " .. message, 2)
|
|
end
|
|
else
|
|
function invariant(message, ...)
|
|
message = Fmt.fmt(message, ...)
|
|
|
|
local fullMessage = string.format(
|
|
"Rojo detected an invariant violation within itself:\n"
|
|
.. "%s\n\n"
|
|
.. "This is a bug in Rojo. Please file an issue:\n"
|
|
.. "https://github.com/rojo-rbx/rojo/issues",
|
|
message
|
|
)
|
|
|
|
error(fullMessage, 2)
|
|
end
|
|
end
|
|
|
|
return invariant
|