File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2+ /* eslint-disable @typescript-eslint/no-var-requires */
23
34const fs = require ( "fs" ) ;
45const 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
You can’t perform that action at this time.
0 commit comments