(parsedCommandLine: ts.ParsedCommandLine, args: string[])
| 143 | } |
| 144 | |
| 145 | function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args: string[]): ParsedCommandLine { |
| 146 | for (let i = 0; i < args.length; i++) { |
| 147 | if (!args[i].startsWith("-")) continue; |
| 148 | |
| 149 | const isShorthand = !args[i].startsWith("--"); |
| 150 | const argumentName = args[i].substring(isShorthand ? 1 : 2); |
| 151 | const option = optionDeclarations.find(option => { |
| 152 | if (option.name.toLowerCase() === argumentName.toLowerCase()) return true; |
| 153 | if (isShorthand && option.aliases) { |
| 154 | return option.aliases.some(a => a.toLowerCase() === argumentName.toLowerCase()); |
| 155 | } |
| 156 | |
| 157 | return false; |
| 158 | }); |
| 159 | |
| 160 | if (option) { |
| 161 | // Ignore errors caused by tstl specific compiler options |
| 162 | parsedCommandLine.errors = parsedCommandLine.errors.filter( |
| 163 | // TS5023: Unknown compiler option '{0}'. |
| 164 | // TS5025: Unknown compiler option '{0}'. Did you mean '{1}'? |
| 165 | e => !((e.code === 5023 || e.code === 5025) && String(e.messageText).includes(`'${args[i]}'.`)) |
| 166 | ); |
| 167 | |
| 168 | const { error, value, consumed } = readCommandLineArgument(option, args[i + 1]); |
| 169 | if (error) parsedCommandLine.errors.push(error); |
| 170 | parsedCommandLine.options[option.name] = value; |
| 171 | if (consumed) { |
| 172 | // Values of custom options are parsed as a file name, exclude them |
| 173 | parsedCommandLine.fileNames = parsedCommandLine.fileNames.filter(f => f !== args[i + 1]); |
| 174 | i += 1; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | return parsedCommandLine; |
| 180 | } |
| 181 | |
| 182 | interface CommandLineArgument extends ReadValueResult { |
| 183 | consumed: boolean; |
no test coverage detected