sounder plugins update
Massimo Melina committed
Jul 19, 2025 at 12:02 UTC
57d4c89e62e04b5927c875bf7d9cd3faefbd6ab0
1 file changed
+15
-11
src/github.ts
+15
-11
@@ -97,18 +97,22 @@ export async function downloadPlugin(repo: Repo, { branch='', overwrite=false }=
97
dest = join(tempInstallPath, dest)
98
return rm(dest, { force: true }).then(() => dest, () => false)
99
})
100
- if (!customRepo) {
101
- const mainFile = join(tempInstallPath, PLUGIN_MAIN_FILE)
102
- const content = await readFile(mainFile, 'utf8')
103
- // force github plugins to have correct repo, in case it is missing, wrong, or just outdated after a rename
104
- if (repo !== parsePluginSource('', content).repo) {
105
- const correct = `exports.repo = ${JSON.stringify(repo)}\n`
106
- let newContent = content.replace(/exports.repo\s*=\s*\S*/g, correct)
107
- if (newContent === content)
108
- newContent = correct + content
109
- await writeFile(mainFile, newContent) // first, as our parsing will consider that (unlike javascript)
100
+ if (!customRepo)
101
+ try {
102
+ const mainFile = join(tempInstallPath, PLUGIN_MAIN_FILE)
103
+ const content = await readFile(mainFile, 'utf8')
104
+ // force github plugins to have correct repo, in case it is missing, wrong, or just outdated after a rename
105
+ if (repo !== parsePluginSource('', content).repo) {
106
+ const correct = `exports.repo = ${JSON.stringify(repo)}\n`
107
+ let newContent = content.replace(/exports.repo\s*=\s*\S*/g, correct)
108
+ if (newContent === content) // no change = the line is missing
109
+ newContent = correct + content
110
+ await writeFile(mainFile, newContent) // first, as our parsing will consider that (unlike javascript)
111
+ }
112
+ }
113
+ catch (e) { // don't abort the whole procedure just because of the check above. It should never fail, but a user reported a mysterious ENOENT on the readFile()
114
+ console.warn("plugin's repo check failed", e)
115
}
111
- }
116
// ready to replace
117
const wasRunning = isPluginRunning(folder)
118
if (wasRunning)