MCPcopy
hub / github.com/vercel/hyper / updatePlugins

Function updatePlugins

app/plugins.ts:99–145  ·  view source on GitHub ↗
({force = false} = {})

Source from the content-addressed store, hash-verified

97let updating = false;
98
99function 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
147function getPluginVersions() {
148 const paths_ = paths.plugins.concat(paths.localPlugins);

Callers 2

commands.tsFile · 0.90
plugins.tsFile · 0.85

Calls 12

installFunction · 0.90
syncPackageJSONFunction · 0.85
getPathsFunction · 0.85
clearCacheFunction · 0.85
requirePluginsFunction · 0.85
getPluginVersionsFunction · 0.85
fnFunction · 0.85
setMethod · 0.80
getMethod · 0.80
notifyFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected