Skip to content

Commit 0ffc0b9

Browse files
committed
Fix: Replace fetch with https in verify-release-assets.js
1 parent 3ddb553 commit 0ffc0b9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

scripts/verify-release-assets.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
#!/usr/bin/env node
2+
/* eslint-disable @typescript-eslint/no-var-requires */
23

34
const fs = require("fs");
45
const path = require("path");
6+
const https = require("https");
7+
8+
/**
9+
* Simple fetch polyfill using https module to avoid dependencies
10+
*/
11+
function fetch(url, options = {}) {
12+
return new Promise((resolve, reject) => {
13+
const req = https.request(url, {
14+
method: options.method || 'GET',
15+
headers: options.headers || {},
16+
}, (res) => {
17+
const chunks = [];
18+
res.on('data', (chunk) => chunks.push(chunk));
19+
res.on('end', () => {
20+
const body = Buffer.concat(chunks).toString('utf8');
21+
resolve({
22+
ok: res.statusCode >= 200 && res.statusCode < 300,
23+
status: res.statusCode,
24+
statusText: res.statusMessage,
25+
text: () => Promise.resolve(body),
26+
json: () => {
27+
try {
28+
return Promise.resolve(JSON.parse(body));
29+
} catch (e) {
30+
return Promise.reject(e);
31+
}
32+
},
33+
});
34+
});
35+
});
36+
37+
req.on('error', (err) => reject(err));
38+
req.end();
39+
});
40+
}
541

642
/**
743
* Verifies that all expected binary assets are present in the GitHub release

0 commit comments

Comments
 (0)