Skip to content

Commit 9386855

Browse files
committed
Bring updater patches from @jayc331
1 parent 4ba1d36 commit 9386855

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/libs/Updater.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ function getMetadata(release: GetReleasesResponse) {
1818
const metadataAsset = release.assets.find((asset) => asset.name === 'metadata.json');
1919
if (!metadataAsset) return;
2020

21-
const metadataUrl = release.assets[1].browser_download_url;
21+
const metadataUrl = metadataAsset.browser_download_url;
2222
const req = Request.get(metadataUrl);
2323
if (req.responseCode !== 200) return;
2424

2525
return JSON.parse(req.text());
2626
}
2727

2828
export function updateScript(path: string, repo: string, configPath: string): boolean {
29-
const scriptFile = path.split('\\').pop();
29+
const scriptFile = path.split(/[/\\]/).pop();
3030
const scriptName = scriptFile.split('.')[0];
3131
const latestRelease = getLatestReleaseInfo(repo);
3232
if (!latestRelease) {
33-
ChatHelper.error('[Updater] Failed to get latest release info');
33+
ChatHelper.error(`[Updater] Failed to get latest release info for '${repo}'`);
3434
return false;
3535
}
3636

@@ -40,7 +40,7 @@ export function updateScript(path: string, repo: string, configPath: string): bo
4040
return false;
4141
}
4242
if (!metadata[scriptName]) {
43-
ChatHelper.error('[Updater] Metadata does not contain script info');
43+
ChatHelper.warn(`[Updater] Metadata does not contain script info for '${scriptName}'`);
4444
return false;
4545
}
4646
const latestVersion = metadata[scriptName].version;
@@ -59,13 +59,13 @@ export function updateScript(path: string, repo: string, configPath: string): bo
5959

6060
const asset = latestRelease.assets.find((asset) => asset.name === scriptFile);
6161
if (!asset) {
62-
ChatHelper.error('[Updater] Failed to find script asset');
62+
ChatHelper.error(`[Updater] Failed to find script asset for '${scriptFile}'`);
6363
return false;
6464
}
6565

6666
const req = Request.get(asset.browser_download_url);
6767
if (req.responseCode !== 200) {
68-
ChatHelper.error('[Updater] Failed to download the latest version');
68+
ChatHelper.error(`[Updater] Failed to download the latest version for '${scriptFile}'`);
6969
return false;
7070
}
7171

0 commit comments

Comments
 (0)