(
configFilePath: string,
configRootDir: string,
cycleCache: Set<string>,
system: ts.System
)
| 70 | } |
| 71 | |
| 72 | function getExtendedTstlOptions( |
| 73 | configFilePath: string, |
| 74 | configRootDir: string, |
| 75 | cycleCache: Set<string>, |
| 76 | system: ts.System |
| 77 | ): TypeScriptToLuaOptions { |
| 78 | const absolutePath = ts.pathIsAbsolute(configFilePath) |
| 79 | ? configFilePath |
| 80 | : ts.pathIsRelative(configFilePath) |
| 81 | ? path.resolve(configRootDir, configFilePath) |
| 82 | : resolveNpmModuleConfig(configFilePath, configRootDir, system); // if a path is neither relative nor absolute, it is probably a npm module |
| 83 | |
| 84 | if (!absolutePath) { |
| 85 | return {}; |
| 86 | } |
| 87 | |
| 88 | const newConfigRoot = path.dirname(absolutePath); |
| 89 | |
| 90 | if (cycleCache.has(absolutePath)) { |
| 91 | return {}; |
| 92 | } |
| 93 | |
| 94 | cycleCache.add(absolutePath); |
| 95 | const fileContent = system.readFile(absolutePath); |
| 96 | const options = {}; |
| 97 | |
| 98 | if (fileContent) { |
| 99 | const { config: parsedConfig } = ts.parseConfigFileTextToJson(configFilePath, fileContent) as { |
| 100 | config?: { |
| 101 | extends?: string | string[]; |
| 102 | tstl?: TypeScriptToLuaOptions; |
| 103 | }; |
| 104 | }; |
| 105 | |
| 106 | if (!parsedConfig) { |
| 107 | return {}; |
| 108 | } |
| 109 | |
| 110 | if (parsedConfig.extends) { |
| 111 | if (Array.isArray(parsedConfig.extends)) { |
| 112 | for (const extendedConfigFile of parsedConfig.extends) { |
| 113 | Object.assign( |
| 114 | options, |
| 115 | getExtendedTstlOptions(extendedConfigFile, newConfigRoot, cycleCache, system) |
| 116 | ); |
| 117 | } |
| 118 | } else { |
| 119 | Object.assign(options, getExtendedTstlOptions(parsedConfig.extends, newConfigRoot, cycleCache, system)); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | if (parsedConfig.tstl) { |
| 124 | Object.assign(options, parsedConfig.tstl); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | return options; |
| 129 | } |
no test coverage detected