Add support to specify major or major.minor versions for tools with GitHub repository

This commit is contained in:
Shivam Mathur
2021-07-05 16:12:58 +05:30
parent 6449431df2
commit e1a9afe11c
4 changed files with 153 additions and 80 deletions

View File

@ -2,6 +2,7 @@ import {IncomingMessage} from 'http';
import * as fs from 'fs';
import * as https from 'https';
import * as path from 'path';
import * as url from 'url';
import * as core from '@actions/core';
/**
@ -46,11 +47,17 @@ export async function getInput(
/**
* Function to fetch an URL
*
* @param url
* @param input_url
*/
export async function fetch(url: string): Promise<string> {
export async function fetch(input_url: string): Promise<string> {
const fetch_promise: Promise<string> = new Promise(resolve => {
const req = https.get(url, (res: IncomingMessage) => {
const url_object: url.UrlObject = new url.URL(input_url);
const options: https.RequestOptions = {
hostname: url_object.hostname,
path: url_object.pathname,
headers: {'User-Agent': 'setup-php'}
};
const req = https.get(options, (res: IncomingMessage) => {
res.setEncoding('utf8');
let body = '';
res.on('data', chunk => (body += chunk));