| 240 | } |
| 241 | |
| 242 | function processLineHook(lines: string[], runtime: ParseRuntime, offset: number, |
| 243 | cb: (err?) => void |
| 244 | ) { |
| 245 | if (offset >= lines.length) { |
| 246 | cb(); |
| 247 | } else { |
| 248 | if (runtime.preFileLineHook) { |
| 249 | const line = lines[offset]; |
| 250 | const res = runtime.preFileLineHook(line, runtime.parsedLineNumber + offset); |
| 251 | offset++; |
| 252 | if (res && (res as PromiseLike<string>).then) { |
| 253 | (res as PromiseLike<string>).then((value) => { |
| 254 | lines[offset - 1] = value; |
| 255 | processLineHook(lines, runtime, offset, cb); |
| 256 | }); |
| 257 | } else { |
| 258 | lines[offset - 1] = res as string; |
| 259 | while (offset < lines.length) { |
| 260 | lines[offset] = runtime.preFileLineHook(lines[offset], runtime.parsedLineNumber + offset) as string; |
| 261 | offset++; |
| 262 | } |
| 263 | cb(); |
| 264 | } |
| 265 | } else { |
| 266 | cb(); |
| 267 | } |
| 268 | } |
| 269 | } |