({force = false} = {})
| 97 | let updating = false; |
| 98 | |
| 99 | function updatePlugins({force = false} = {}) { |
| 100 | if (updating) { |
| 101 | return notify('Plugin update in progress'); |
| 102 | } |
| 103 | updating = true; |
| 104 | syncPackageJSON(); |
| 105 | const id_ = id; |
| 106 | install((err) => { |
| 107 | updating = false; |
| 108 | |
| 109 | if (err) { |
| 110 | notify('Error updating plugins.', err, {error: err}); |
| 111 | } else { |
| 112 | // flag successful plugin update |
| 113 | cache.set('hyper.plugins', id_); |
| 114 | |
| 115 | // cache paths |
| 116 | paths = getPaths(); |
| 117 | |
| 118 | // clear require cache |
| 119 | clearCache(); |
| 120 | |
| 121 | // cache modules |
| 122 | modules = requirePlugins(); |
| 123 | |
| 124 | const loaded = modules.length; |
| 125 | const total = paths.plugins.length + paths.localPlugins.length; |
| 126 | const pluginVersions = JSON.stringify(getPluginVersions()); |
| 127 | const changed = cache.get('hyper.plugin-versions') !== pluginVersions && loaded === total; |
| 128 | cache.set('hyper.plugin-versions', pluginVersions); |
| 129 | |
| 130 | // notify watchers |
| 131 | watchers.forEach((fn) => { |
| 132 | fn(err, {force}); |
| 133 | }); |
| 134 | |
| 135 | if (force || changed) { |
| 136 | if (changed) { |
| 137 | notify('Plugins Updated', 'Restart the app or hot-reload with "View" > "Reload" to enjoy the updates!'); |
| 138 | } else { |
| 139 | notify('Plugins Updated', 'No changes!'); |
| 140 | } |
| 141 | checkDeprecatedExtendKeymaps(); |
| 142 | } |
| 143 | } |
| 144 | }); |
| 145 | } |
| 146 | |
| 147 | function getPluginVersions() { |
| 148 | const paths_ = paths.plugins.concat(paths.localPlugins); |
no test coverage detected