* Normalizes banner options and compiles the configured banner source into a * function that can render per-asset banner text. * @param {BannerPluginArgument} options options object
(options)
| 50 | * @param {BannerPluginArgument} options options object |
| 51 | */ |
| 52 | constructor(options) { |
| 53 | if (typeof options === "string" || typeof options === "function") { |
| 54 | options = { |
| 55 | banner: options |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | /** @type {BannerPluginOptions} */ |
| 60 | this.options = options; |
| 61 | |
| 62 | const bannerOption = options.banner; |
| 63 | if (typeof bannerOption === "function") { |
| 64 | const getBanner = bannerOption; |
| 65 | /** @type {BannerFunction} */ |
| 66 | this.banner = this.options.raw |
| 67 | ? getBanner |
| 68 | : /** @type {BannerFunction} */ (data) => wrapComment(getBanner(data)); |
| 69 | } else { |
| 70 | const banner = this.options.raw |
| 71 | ? bannerOption |
| 72 | : wrapComment(bannerOption); |
| 73 | /** @type {BannerFunction} */ |
| 74 | this.banner = () => banner; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Validates the configured options and injects rendered banner comments into |
nothing calls this directly
no test coverage detected