@lumi-ai-lab/harness-data 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/github.js +17 -3
package/package.json
CHANGED
package/src/lib/github.js
CHANGED
|
@@ -47,11 +47,25 @@ export function findReleaseAsset(release, name) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export async function downloadReleaseAsset(asset, file, options = {}) {
|
|
50
|
-
const
|
|
51
|
-
await download(asset.url, file, headers, {
|
|
50
|
+
const downloadOptions = {
|
|
52
51
|
progressLabel: options.progressLabel,
|
|
53
52
|
log: options.log,
|
|
54
53
|
progress: options.progress,
|
|
55
54
|
progressWriter: options.progressWriter
|
|
56
|
-
}
|
|
55
|
+
};
|
|
56
|
+
const publicUrl = asset.browser_download_url || asset.url;
|
|
57
|
+
const token = githubToken(options);
|
|
58
|
+
|
|
59
|
+
if (token) {
|
|
60
|
+
const headers = { ...githubHeaders(options), Accept: "application/octet-stream" };
|
|
61
|
+
try {
|
|
62
|
+
await download(asset.url, file, headers, downloadOptions);
|
|
63
|
+
return;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
fs.rmSync(file, { force: true });
|
|
66
|
+
if (!asset.browser_download_url) throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await download(publicUrl, file, { "User-Agent": userAgent }, downloadOptions);
|
|
57
71
|
}
|