(
fileName: string,
options: ClassifyScriptFileOptions = {},
)
| 37 | } |
| 38 | |
| 39 | export function classifyScriptFileName( |
| 40 | fileName: string, |
| 41 | options: ClassifyScriptFileOptions = {}, |
| 42 | ): ClassifiedScriptFile { |
| 43 | const normalized = normalizeLuaLikeFileName(fileName); |
| 44 | const base = normalized.replace(/\.luau$/i, ""); |
| 45 | |
| 46 | const normalizeName = (name: string) => |
| 47 | options.stripDisambiguationSuffix |
| 48 | ? stripScriptDisambiguationSuffix(name) |
| 49 | : name; |
| 50 | |
| 51 | if (base.endsWith(".server")) { |
| 52 | return { |
| 53 | className: "Script", |
| 54 | scriptName: normalizeName(base.replace(/\.server$/, "")), |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | if (base.endsWith(".client")) { |
| 59 | return { |
| 60 | className: "LocalScript", |
| 61 | scriptName: normalizeName(base.replace(/\.client$/, "")), |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | if (base.endsWith(".module")) { |
| 66 | return { |
| 67 | className: "ModuleScript", |
| 68 | scriptName: normalizeName(base.replace(/\.module$/, "")), |
| 69 | }; |
| 70 | } |
| 71 | |
| 72 | return { |
| 73 | className: "ModuleScript", |
| 74 | scriptName: normalizeName(base), |
| 75 | }; |
| 76 | } |
no test coverage detected