(this: PluginContext)
| 98 | } |
| 99 | |
| 100 | function setupFileEmitter(this: PluginContext) { |
| 101 | useConfig(service, { |
| 102 | actions: { |
| 103 | handleFile: (context, event) => { |
| 104 | try { |
| 105 | const { file: f } = narrowEvent(event, 'EMIT_FILE') |
| 106 | const file = Object.assign({}, f) |
| 107 | |
| 108 | if (file.type === 'chunk') |
| 109 | file.fileName = getJsFilename(file.fileName) |
| 110 | |
| 111 | const refId = this.emitFile(file) |
| 112 | service.send( |
| 113 | model.events.REF_ID({ |
| 114 | id: file.id, |
| 115 | fileId: refId, |
| 116 | }), |
| 117 | ) |
| 118 | |
| 119 | const emittedFile = { ...file, refId } |
| 120 | filesByRefId.set(refId, emittedFile) |
| 121 | filesByFileName.set(file.fileName, emittedFile) |
| 122 | |
| 123 | this.addWatchFile(file.id) |
| 124 | } catch (error) { |
| 125 | service.send(model.events.ERROR(error)) |
| 126 | } |
| 127 | }, |
| 128 | }, |
| 129 | }) |
| 130 | } |
| 131 | |
| 132 | async function addFiles( |
| 133 | this: PluginContext, |
nothing calls this directly
no test coverage detected