MCPcopy Index your code
hub / github.com/ember-cli/ember-cli / init

Function init

lib/models/addon.js:255–308  ·  view source on GitHub ↗

Initializes the addon. If you override this method make sure and call `this._super.init && this._super.init.apply(this, arguments);` or your addon will not work. @public @method init @param {Project|Addon} parent The project or addon that directly depends on this addon @param {Proj

(parent, project)

Source from the content-addressed store, hash-verified

253 ```
254 */
255 init(parent, project) {
256 this._super();
257 this.parent = parent;
258 this.project = project;
259 this.ui = project && project.ui;
260 this.addonPackages = Object.create(null);
261 this.addons = [];
262 this.registry = p.defaultRegistry(this);
263
264 if (!this.root) {
265 throw new Error('Addon classes must be instantiated with the `root` property');
266 }
267
268 if (!this.name) {
269 throw new SilentError(`An addon must define a \`name\` property (found at ${this.root}).`);
270 }
271
272 this._nodeModulesPath = null;
273
274 this.treePaths = {
275 app: 'app',
276 styles: 'app/styles',
277 templates: 'app/templates',
278 addon: 'addon',
279 'addon-styles': 'addon/styles',
280 'addon-templates': 'addon/templates',
281 vendor: 'vendor',
282 'test-support': 'test-support',
283 'addon-test-support': 'addon-test-support',
284 public: 'public',
285 };
286
287 this.treeForMethods = defaultsDeep({}, DEFAULT_TREE_FOR_METHODS);
288
289 if (this.parent) {
290 // The parent should already have a packageInfoCache.
291 // Because it does, this package should already be in the cache.
292 this.packageInfoCache = this.parent.packageInfoCache;
293 }
294
295 if (!this.packageInfoCache) {
296 // this is most likely a 'root' addon, so create a new PackageInfoCache
297 // for it so we get the PackageInfo for it and its children.
298 //
299 // this may also be someone who failed to mock their addon correctly in testing.
300 this.packageInfoCache = new PackageInfoCache(this.ui);
301 }
302
303 this._packageInfo = this.packageInfoCache.loadAddon(this);
304
305 p.setupRegistry(this);
306
307 this._initDefaultBabelOptions();
308 },
309
310 _initDefaultBabelOptions() {
311 this.options = defaultsDeep(this.options, {

Callers

nothing calls this directly

Calls 2

createMethod · 0.80
loadAddonMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…