@@ -10,7 +10,6 @@ local LuauPolyfill = require("@pkg/@jsdotlua/luau-polyfill")
1010local Array = LuauPolyfill .Array
1111local Error = LuauPolyfill .Error
1212local String = LuauPolyfill .String
13- local console = LuauPolyfill .console
1413type Array <T> = LuauPolyfill .Array <T>
1514
1615local exports = {}
@@ -23,15 +22,18 @@ local chalk = require("@pkg/@jsdotlua/chalk")
2322-- local fs = require("@pkg/graceful-fs")
2423-- local slash = require("@pkg/slash")
2524-- ROBLOX deviation END
25+ local jestValidateModule = require (" @pkg/@jsdotlua/jest-validate" )
26+ local ValidationError = jestValidateModule .ValidationError
2627local typesModule = require (" @pkg/@jsdotlua/jest-types" )
2728type Config_Path = typesModule .Config_Path
2829local constantsModule = require (" ./constants" )
2930local JEST_CONFIG_BASE_NAME = constantsModule .JEST_CONFIG_BASE_NAME
31+ local JEST_CONFIG_EXT_ORDER = constantsModule .JEST_CONFIG_EXT_ORDER
3032-- ROBLOX deviation START: not needed
31- -- local JEST_CONFIG_EXT_ORDER = constantsModule.JEST_CONFIG_EXT_ORDER
3233-- local PACKAGE_JSON = constantsModule.PACKAGE_JSON
3334-- ROBLOX deviation END
3435local utilsModule = require (" ./utils" )
36+ local BULLET = utilsModule .BULLET
3537local DOCUMENTATION_NOTE = utilsModule .DOCUMENTATION_NOTE
3638
3739-- ROBLOX deviation START: predefine functions
@@ -127,7 +129,7 @@ function resolveConfigPathByTraversing(
127129 end ) :: Array <any>
128130 ) :: Array <ModuleScript>
129131 if not skipMultipleConfigWarning and # configFiles > 1 then
130- console . warn (makeMultipleConfigsWarning (configFiles ))
132+ error ( ValidationError . new (makeMultipleConfigsWarning (configFiles ) ))
131133 end
132134 if # configFiles > 0 then
133135 return configFiles [1 ]
@@ -175,26 +177,18 @@ function makeResolutionErrorMessage(
175177 cwd : Instance
176178): string
177179 return " Could not find a config file based on provided values:\n "
178- .. ( ' path: "%s "\n ' ): format ( tostring ( initialPath ))
179- .. ( ' cwd: "%s "\n ' ): format ( tostring ( cwd ))
180+ .. ` path: "{initialPath} "\n`
181+ .. ` cwd: "{cwd} "\n`
180182 -- ROBLOX deviation START: align message to make more sense in Luau context
181183 .. " Config paths must be specified by either a direct path to a config script\n "
182184 .. " or a path to a directory. If directory is given, Jest will try to\n "
183185 -- ROBLOX deviation END
184- .. (" traverse directory tree up, until it finds one of those files in exact order: %s." ):format (
185- Array .join (
186- Array .map (
187- -- ROBLOX deviation START: only support Lua config files
188- -- JEST_CONFIG_EXT_ORDER
189- { " .lua" },
190- -- ROBLOX deviation END
191- function (ext )
192- return (' "%s"' ):format ((getConfigFilename (ext )))
193- end
194- ),
195- " or "
196- )
197- )
186+ .. ` traverse directory tree up, until it finds one of those files in exact order: {Array.join(
187+ Array .map (JEST_CONFIG_EXT_ORDER , function (ext )
188+ return ` "{getConfigFilename(ext)}"`
189+ end ),
190+ " or "
191+ )}.`
198192end
199193
200194local function extraIfPackageJson (configPath : Config_Path )
@@ -206,14 +200,14 @@ local function extraIfPackageJson(configPath: Config_Path)
206200 return " "
207201end
208202
209- function makeMultipleConfigsWarning (configPaths : Array<ModuleScript> )
210- return chalk .yellow ({
203+ function makeMultipleConfigsWarning (configPaths : Array<ModuleScript> ): ( string , string , string )
204+ return ` {BULLET}{ chalk.bold("Multiple configurations found")} ` ,
211205 Array .join (
212206 Array .concat (
213- {},
214- { chalk .bold (" \u{25cf} Multiple configurations found:" ) },
215207 Array .map (configPaths , function (configPath )
216- return (" * %s%s" ):format (tostring (extraIfPackageJson (configPath )), tostring (configPath ))
208+ -- ROBLOX deviation START: replace slash command with GetFullName
209+ return ` * {extraIfPackageJson(configPath)}{configPath:GetFullName()}`
210+ -- ROBLOX deviation END
217211 end ),
218212 {
219213 " " ,
@@ -223,8 +217,7 @@ function makeMultipleConfigsWarning(configPaths: Array<ModuleScript>)
223217 ),
224218 " \n "
225219 ),
226- DOCUMENTATION_NOTE ,
227- })
220+ DOCUMENTATION_NOTE
228221end
229222
230223return exports
0 commit comments