Skip to content

Commit 803b16a

Browse files
committed
feat: remove old extension versions on update
1 parent d7503e4 commit 803b16a

File tree

1 file changed

+9
-2
lines changed
  • packages/electron-chrome-web-store/src/browser

1 file changed

+9
-2
lines changed

packages/electron-chrome-web-store/src/browser/updater.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as fs from 'node:fs'
12
import * as path from 'node:path'
23
import { app, powerMonitor } from 'electron'
34

@@ -231,7 +232,8 @@ async function updateExtension(session: Electron.Session, update: ExtensionUpdat
231232
await session.loadExtension(updateDir)
232233
d('loaded update %s@%s', update.id, update.version)
233234

234-
// TODO: remove old extension
235+
// Remove old version
236+
await fs.promises.rm(oldExtension.path, { recursive: true, force: true })
235237
}
236238

237239
async function checkForUpdates(session: Electron.Session) {
@@ -248,7 +250,12 @@ async function checkForUpdates(session: Electron.Session) {
248250

249251
d('updating %d extension(s)', updates.length)
250252
for (const update of updates) {
251-
await updateExtension(session, update)
253+
try {
254+
await updateExtension(session, update)
255+
} catch (error) {
256+
console.error(`checkForUpdates: Error updating extension ${update.id}`)
257+
console.error(error)
258+
}
252259
}
253260
}
254261

0 commit comments

Comments
 (0)