(pluginName: string)
| 169 | } |
| 170 | |
| 171 | public update(pluginName: string) { |
| 172 | if (!this.has(pluginName)) { |
| 173 | throw new NotFoundError('该插件不存在'); |
| 174 | } |
| 175 | return new Promise((resolve, reject) => { |
| 176 | const update = () => { |
| 177 | npm.commands.update([pluginName, this.pluginInstallDir], async err => { |
| 178 | if (err) { |
| 179 | return reject(err); |
| 180 | } |
| 181 | const plugins = this.getPlugins(); |
| 182 | const plugin = plugins.find(p => p.name === pluginName); |
| 183 | if (plugin) { |
| 184 | plugin.version = await this.getPluginVersion(pluginName); |
| 185 | } |
| 186 | this.setPlugins(plugins); |
| 187 | return resolve(plugins); |
| 188 | }); |
| 189 | }; |
| 190 | |
| 191 | const pluginConfig = this.plugins[pluginName]; |
| 192 | const npmConfig = { loglevel: 'silent', prefix: this.pluginInstallDir, registry: pluginConfig.registry }; |
| 193 | this.loadNpmConfig(npmConfig, update); |
| 194 | }); |
| 195 | } |
| 196 | |
| 197 | /** |
| 198 | * 删除插件库 |
nothing calls this directly
no test coverage detected