* Resets all installed drivers and extensions
(driverConfig: DriverConfig, pluginConfig: PluginConfig)
| 105 | * Resets all installed drivers and extensions |
| 106 | */ |
| 107 | async function resetAllExtensions(driverConfig: DriverConfig, pluginConfig: PluginConfig): Promise<void> { |
| 108 | const commandConfigs: [CliExtensionCommand, DriverConfig | PluginConfig][] = [ |
| 109 | ['driver', driverConfig], |
| 110 | ['plugin', pluginConfig], |
| 111 | ]; |
| 112 | for (const [command, config] of commandConfigs) { |
| 113 | for (const extensionName of Object.keys(config.installedExtensions)) { |
| 114 | try { |
| 115 | await uninstallExtension(extensionName, extensionCommandArgs(command, extensionName, 'uninstall'), config); |
| 116 | } catch (e) { |
| 117 | log.warn( |
| 118 | `${extensionName} ${command} cannot be uninstalled. Will delete the manifest anyway. ` + |
| 119 | `Original error: ${e instanceof Error ? e.stack : String(e)}`, |
| 120 | ); |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | const manifestPath = config.manifestPath; |
| 125 | if (!manifestPath || !(await fs.exists(manifestPath))) { |
| 126 | continue; |
| 127 | } |
| 128 | |
| 129 | await fs.rimraf(manifestPath); |
| 130 | if (await fs.exists(manifestPath)) { |
| 131 | throw new Error(`${command} manifest at '${manifestPath}' cannot be deleted. Is it accessible?`); |
| 132 | } else { |
| 133 | log.info(`Successfully deleted ${command} manifest at '${manifestPath}'`); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Install drivers listed in DEFAULT_DRIVERS. |
no test coverage detected