| 188 | } |
| 189 | |
| 190 | dependency(dependencies, after) { |
| 191 | |
| 192 | Hoek.assert(this.realm.plugin, 'Cannot call dependency() outside of a plugin'); |
| 193 | Hoek.assert(!after || typeof after === 'function', 'Invalid after method'); |
| 194 | |
| 195 | // Normalize to { plugin: version } |
| 196 | |
| 197 | if (typeof dependencies === 'string') { |
| 198 | dependencies = { [dependencies]: '*' }; |
| 199 | } |
| 200 | else if (Array.isArray(dependencies)) { |
| 201 | const map = {}; |
| 202 | for (const dependency of dependencies) { |
| 203 | map[dependency] = '*'; |
| 204 | } |
| 205 | |
| 206 | dependencies = map; |
| 207 | } |
| 208 | |
| 209 | this._core.dependencies.push({ plugin: this.realm.plugin, deps: dependencies }); |
| 210 | |
| 211 | if (after) { |
| 212 | this.ext('onPreStart', after, { after: Object.keys(dependencies) }); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | encoder(encoding, encoder) { |
| 217 | |