File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed
Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change 11import * as fs from "node:fs" ;
22import type { Config } from "../types/config" ;
33import { info } from "@actions/core" ;
4+ import { get } from "node:https" ;
45
56export const cwd = ( ) : string => {
67 const path = process . env . GITHUB_WORKSPACE ;
@@ -19,15 +20,31 @@ export const fileExists = (config: Config, filename: string): boolean =>
1920 fs . existsSync ( filePath ( config , filename ) ) ;
2021
2122export const readRemoteFile = async ( url : string ) : Promise < string > => {
22- const response : Response = await fetch ( url ) ;
23+ return new Promise ( ( resolve ) => {
24+ get ( url , ( res ) => {
25+ if ( res . statusCode !== 200 ) {
26+ info (
27+ `Failed to fetch ${ url } with status code ${ res . statusCode } ` ,
28+ ) ;
29+ resolve ( "" ) ;
2330
24- if ( ! response . ok ) {
25- info ( `Failed to fetch ${ url } with status code ${ response . status } ` ) ;
31+ return ;
32+ }
2633
27- return "" ;
28- }
34+ let data = "" ;
35+
36+ res . on ( "data" , ( chunk ) => {
37+ data += chunk ;
38+ } ) ;
2939
30- return response . text ( ) ;
40+ res . on ( "end" , ( ) => {
41+ resolve ( data ) ;
42+ } ) ;
43+ } ) . on ( "error" , ( err ) => {
44+ info ( `Failed to fetch ${ url } with error: ${ err . message } ` ) ;
45+ resolve ( "" ) ;
46+ } ) ;
47+ } ) ;
3148} ;
3249
3350export const readFile = ( config : Config , filename : string ) : string => {
You can’t perform that action at this time.
0 commit comments