* Parse a (top-level) lua script * @param filename - the full path to the script * @param content - the content of the script * @param cache - cache
(
filename: string,
content: string,
dir: string,
cache?: Map<string, ScriptMetadata>,
isLoadingIncludes = false,
)
| 349 | * @param cache - cache |
| 350 | */ |
| 351 | async parseScript( |
| 352 | filename: string, |
| 353 | content: string, |
| 354 | dir: string, |
| 355 | cache?: Map<string, ScriptMetadata>, |
| 356 | isLoadingIncludes = false, |
| 357 | ): Promise<ScriptMetadata> { |
| 358 | const { name, numberOfKeys } = splitFilename(filename); |
| 359 | const filePath = isLoadingIncludes ? filename : name; |
| 360 | const meta = cache?.get(filePath); |
| 361 | if (meta?.content === content) { |
| 362 | return meta; |
| 363 | } |
| 364 | const fileInfo: ScriptMetadata = { |
| 365 | dir, |
| 366 | path: filePath, |
| 367 | token: getPathHash(filePath), |
| 368 | content, |
| 369 | name, |
| 370 | numberOfKeys, |
| 371 | includes: [], |
| 372 | }; |
| 373 | |
| 374 | await this.resolveDependencies(fileInfo, cache, isLoadingIncludes); |
| 375 | return fileInfo; |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Construct the final version of a file by interpolating its includes in dependency order. |
no test coverage detected