* Loads a compiled loopback datasource by name * @param name - {string} * @returns {*}
(name)
| 56 | * @returns {*} |
| 57 | */ |
| 58 | function loadDataSourceByName(name) { |
| 59 | debug(`Searching for specified dataSource ${name}`); |
| 60 | const dataSourceFiles = getAllDataSourceFiles(); |
| 61 | debug(`Loaded ${dataSourceFiles.length} dataSource files`); |
| 62 | |
| 63 | // eslint-disable-next-line @typescript-eslint/prefer-for-of |
| 64 | for (let i = 0; i < dataSourceFiles.length; i++) { |
| 65 | const f = dataSourceFiles[i]; |
| 66 | const ds = loadDataSource(path.resolve(DEFAULT_DATASOURCE_DIRECTORY, f)); |
| 67 | if (ds.name === name) { |
| 68 | debug(`Found dataSource ${name}`); |
| 69 | return ds; |
| 70 | } else { |
| 71 | debug(`Did not match dataSource ${name} !== ${ds.name}`); |
| 72 | } |
| 73 | } |
| 74 | throw new Error( |
| 75 | `Cannot find datasource "${name}" in ${DEFAULT_DATASOURCE_DIRECTORY}`, |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | const DEFAULT_DATASOURCE_DIRECTORY = './dist/datasources'; |
| 80 |
nothing calls this directly
no test coverage detected