我试图创建一个使用蓝图 afterInstall
挂钩的 Ember 插件。
我已阅读https://cli.emberjs.com/release/writing-addons/addon-blueprints/
我的插件叫做hello-world
.
我生成了我的插件蓝图 ember generate blueprint hello-world
。
我现在有一个blueprint/hello-world/index.js
文件。
'use strict';
module.exports = {
description: 'This is my blueprint',
afterInstall(options) {
console.log('hello');
return this.addPackagesToProject([
{ name: 'lodash' }
]);
}
};
我怎么能测试afterInstall
钩子被调用?
我的 Ember 插件正在开发中(尚未发布),我尝试 npm link
在我的 Ember 插件目录和 npm link hello-world
我的 Ember 应用程序中使用。这会在我的 Ember 应用程序 node_modules 中创建一个符号链接,以指向我的 hello-world Ember 插件,但它不会触发 afterInstall
钩子。
我的 Ember 应用程序 package.json 没有lodash
在依赖项或 devDependencies 中获得条目。
我的 Ember 应用程序 package.json 的一部分
"devDependencies": {
...
"hello-world": "*"
...
}
运行npm install --offline
似乎不会触发蓝图钩子。