I'm writting a cordova hook which updates plugins on before_prepare
.
Three questions here:
- I'm getting the error: [TypeError: Cannot read property 'buffer' of undefined]
- I would like to stop the flow until the plugin has been updated
- Is it possible to know if a plugin was added from cordova plugin registry or from a git repo?
The code I'm using:
var plugin = context.requireCordovaModule('cordova-lib/src/cordova/plugin'),
pluginNames = context.opts.cordova.plugins;
function updatePlugin(pluginNames) {
pluginNames.forEach(function (pluginName) {
return removePlugin(pluginName).then(function () {
addPlugin(pluginName);
}, function(e) {
console.log(e); // ERROR: [TypeError: Cannot read property 'buffer' of undefined]
});
});
}
function removePlugin(pluginNames) {
return plugin('rm', pluginNames);
}
function addPlugin(pluginNames) {
return plugin('add', pluginNames);
}
updatePlugin(pluginNames);