(reader, style)
| 244 | } |
| 245 | |
| 246 | _addWriter(reader, style) { |
| 247 | const {namespaceWriter, generalWriter} = this._getWriter(); |
| 248 | |
| 249 | if ((style === "runtime" || style === "dist") && this._isRuntimeNamespaced) { |
| 250 | // If the project's type requires a namespace at runtime, the |
| 251 | // dist- and runtime-style paths are identical to buildtime-style paths |
| 252 | style = "buildtime"; |
| 253 | } |
| 254 | const readers = []; |
| 255 | switch (style) { |
| 256 | case "buildtime": |
| 257 | // Writer already uses buildtime style |
| 258 | readers.push(namespaceWriter); |
| 259 | readers.push(generalWriter); |
| 260 | break; |
| 261 | case "runtime": |
| 262 | case "dist": |
| 263 | // Runtime is not namespaced: link namespace to / |
| 264 | readers.push(resourceFactory.createFlatReader({ |
| 265 | reader: namespaceWriter, |
| 266 | namespace: this._namespace |
| 267 | })); |
| 268 | // Add general writer as is |
| 269 | readers.push(generalWriter); |
| 270 | break; |
| 271 | case "flat": |
| 272 | // Rewrite paths from "flat" to "buildtime" |
| 273 | readers.push(resourceFactory.createFlatReader({ |
| 274 | reader: namespaceWriter, |
| 275 | namespace: this._namespace |
| 276 | })); |
| 277 | // General writer resources can't be flattened, so they are not available |
| 278 | break; |
| 279 | default: |
| 280 | throw new Error(`Unknown path mapping style ${style}`); |
| 281 | } |
| 282 | readers.push(reader); |
| 283 | |
| 284 | return resourceFactory.createReaderCollectionPrioritized({ |
| 285 | name: `Reader/Writer collection for project ${this.getName()}`, |
| 286 | readers |
| 287 | }); |
| 288 | } |
| 289 | |
| 290 | /* === Internals === */ |
| 291 | /** |
no test coverage detected