hooks/after_plugin_add/register_plugins.js is supposed to make sure that for a "cordova plugin add ...", a line is added to package.json, more precisely, to the cordovaPlugins array. A "ionic state restore" is able to install all plugins from the cordovaPlugins, e.g. after you check out your app from a git repo that doesn't contain the plugins directory.
There's a check in register_plugins.js that is supposed to make sure that cordovaPlugins doesn't contain duplicates. Here's how the check is being currently done:
if (packageJSON.cordovaPlugins.indexOf(plugin) !== -1) {
packageJSON.cordovaPlugins.push(plugin);
}
"!== -1" should read "== -1". This bug causes only those plugins to be added to package.json which are already in there. If you add a new plugin, package.json won't be changed. You can add plugin entries manually, but every "ionic state restore" call (which internally calls "cordova plugin add ..." for all plugins in package.json) will duplicate the plugins list.
hooks/after_plugin_add/register_plugins.js is supposed to make sure that for a "cordova plugin add ...", a line is added to package.json, more precisely, to the cordovaPlugins array. A "ionic state restore" is able to install all plugins from the cordovaPlugins, e.g. after you check out your app from a git repo that doesn't contain the plugins directory.
There's a check in register_plugins.js that is supposed to make sure that cordovaPlugins doesn't contain duplicates. Here's how the check is being currently done:
"!== -1"
should read"== -1"
. This bug causes only those plugins to be added to package.json which are already in there. If you add a new plugin, package.json won't be changed. You can add plugin entries manually, but every "ionic state restore" call (which internally calls "cordova plugin add ..." for all plugins in package.json) will duplicate the plugins list.