jeudi 12 mars 2020

ember-addon - afterInstall hook does not update my ember app package.json

Im trying to create an Ember Addon that uses the blueprint afterInstall hook.

I have read https://cli.emberjs.com/release/writing-addons/addon-blueprints/

My addon is called hello-world.

I generated my addon blueprint by ember generate blueprint hello-world.

I have now a blueprint/hello-world/index.js file.

'use strict';

module.exports = {
  description: 'This is my blueprint',
  afterInstall(options) {
    console.log('hello');

    return this.addPackagesToProject([
      { name: 'lodash' }
    ]);
  }
};

How could I test the the afterInstall hook is called?

My Ember Addon is in development (and has not been published), I have tried using npm link in my Ember Addon directory and npm link hello-world in my Ember app. This creates a symlink in my Ember App node_modules to point to my hello-world Ember Addon but it does not trigger the afterInstall hook.

My Ember App package.json does not get an entry for lodash in dependencies or devDependencies.

Part of my Ember App package.json

"devDependencies": {
    ...
    "hello-world": "*"
    ...
  }

Running npm install --offline does not seem to trigger the blueprint hook.




Aucun commentaire:

Enregistrer un commentaire