| 37 | const watchMode = Boolean(cli.flags.watch || cli.flags.w) |
| 38 | |
| 39 | function checkSchemasForDuplicates(allTableSchemas: TableSchema[]) { |
| 40 | for (const schema of allTableSchemas) { |
| 41 | const schemasMatchingThatName = allTableSchemas.filter( |
| 42 | someSchema => someSchema.tableName === schema.tableName |
| 43 | ) |
| 44 | if (schemasMatchingThatName.length > 1) { |
| 45 | throw new Error( |
| 46 | `Table "${schema.tableName}" has been defined more than once:\n` + |
| 47 | schemasMatchingThatName |
| 48 | .map(duplicate => { |
| 49 | const lineRef = duplicate.loc ? `:${duplicate.loc.start.line}` : `` |
| 50 | return ` - ${duplicate.sourceFile.filePath}${lineRef}` |
| 51 | }) |
| 52 | .join("\n") |
| 53 | ) |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | function run(sourceFilePaths: string[], moreSchemas: TableSchema[] = []) { |
| 59 | let allQueries: QueryInvocation[] = [] |