()
| 3 | import { stderr } from '../logging'; |
| 4 | |
| 5 | export function waitForInputPlugin(): Plugin { |
| 6 | return { |
| 7 | async buildStart(this: PluginContext, options: NormalizedInputOptions) { |
| 8 | const inputSpecifiers = Array.isArray(options.input) |
| 9 | ? options.input |
| 10 | : Object.keys(options.input); |
| 11 | |
| 12 | let lastAwaitedSpecifier: string | null = null; |
| 13 | checkSpecifiers: while (true) { |
| 14 | for (const specifier of inputSpecifiers) { |
| 15 | if ((await this.resolve(specifier)) === null) { |
| 16 | if (lastAwaitedSpecifier !== specifier) { |
| 17 | stderr(`waiting for input ${bold(specifier)}...`); |
| 18 | lastAwaitedSpecifier = specifier; |
| 19 | } |
| 20 | await new Promise(resolve => setTimeout(resolve, 500)); |
| 21 | continue checkSpecifiers; |
| 22 | } |
| 23 | } |
| 24 | break; |
| 25 | } |
| 26 | }, |
| 27 | name: 'wait-for-input' |
| 28 | }; |
| 29 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…