[英]How grunt plugin get initialized?
I have understood the concept of "require" and "module.export". 我已经了解了“ require”和“ module.export”的概念。 Now as per my understanding if one file is exporting a module another file invoking that by using "require".
现在根据我的理解,如果一个文件正在导出模块,则另一个文件通过使用“ require”来调用。
Now in writing grunt task , we write 现在在编写grunt任务时,我们写
module.exports = function(grunt){}
Now who requires the module and how grunt argument is passed? 现在谁需要模块,如何传递grunt参数? I mean how does it work?
我是说它如何运作?
Also if some one can tell me what is the life cycle of a node plugin? 另外,是否有人可以告诉我节点插件的生命周期是什么?
Basically grunt is doing the require and than calling that exported function with its instance of grunt. 基本上grunt是在执行需求,而不是使用grunt实例调用导出的函数。 you can see it in: task.js
您可以在以下位置看到它: task.js
// Load taskfile.
fn = require(path.resolve(filepath));
if (typeof fn === 'function') {
fn.call(grunt, grunt);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.