使用 modules.exports 函数时 Cordova 挂钩不是 运行
Cordova hook not running when using modules.exports function
我创建了一个 after_prepare
挂钩:
#!/usr/bin/env node
module.exports = function(context) {
... some code
console.log('Hey, a hook');
}
当我 运行 cordova build android
时,我在终端中看到它说它正在 运行ning 我的钩子,但它似乎不是 运行ning module.exports 函数,因为控制台中没有显示 console.log。
我解决了!
我在 config.xml 文件中添加了钩子
<hook type="after_prepare" src="hooks/after_prepare/020_add_android_permissions.js"/>
现在它执行module.exports
函数下的代码。
更新:这是工作 example
我创建了一个 after_prepare
挂钩:
#!/usr/bin/env node
module.exports = function(context) {
... some code
console.log('Hey, a hook');
}
当我 运行 cordova build android
时,我在终端中看到它说它正在 运行ning 我的钩子,但它似乎不是 运行ning module.exports 函数,因为控制台中没有显示 console.log。
我解决了!
我在 config.xml 文件中添加了钩子
<hook type="after_prepare" src="hooks/after_prepare/020_add_android_permissions.js"/>
现在它执行module.exports
函数下的代码。
更新:这是工作 example