Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function queryLatestMatch(versionSpec: string): Promise {
//
// Hopefully your tool supports an easy way to get a version list.
// Node offers a json list of versions.
//
let dataFileName: string;
switch (osPlat) {
case "linux": dataFileName = "linux-" + osArch; break;
case "darwin": dataFileName = "osx-" + osArch + '-tar'; break;
case "win32": dataFileName = "win-" + osArch + '-exe'; break;
default: throw new Error(`Unexpected OS '${osPlat}'`);
}
let versions: string[] = [];
let dataUrl = "https://nodejs.org/dist/index.json";
let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
let nodeVersions: INodeVersion[] = (await rest.get(dataUrl)).result;
nodeVersions.forEach((nodeVersion:INodeVersion) => {
//
// Ensure this version supports your os and platform.
//
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
versions.push(nodeVersion.version);
}
});
//
// If there is no data driven way to get versions supported,
// a last option is to tool.scrape() with a regex.
//
// For example:
// let scrapeUrl = 'https://nodejs.org/dist/';
async function queryLatestMatch(versionSpec: string): Promise {
// node offers a json list of versions
let dataFileName: string;
switch (osPlat) {
case "linux": dataFileName = "linux-" + osArch; break;
case "darwin": dataFileName = "osx-" + osArch + '-tar'; break;
case "win32": dataFileName = "win-" + osArch + '-exe'; break;
default: throw new Error(`Unexpected OS '${osPlat}'`);
}
let versions: string[] = [];
let dataUrl = "https://nodejs.org/dist/index.json";
let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
let nodeVersions: INodeVersion[] = (await rest.get(dataUrl)).result;
nodeVersions.forEach((nodeVersion:INodeVersion) => {
// ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
versions.push(nodeVersion.version);
}
});
// get the latest version that matches the version spec
let version: string = toolLib.evaluateVersions(versions, versionSpec);
return version;
}
case 'linux':
dataFileName = 'linux-' + osArch;
break;
case 'darwin':
dataFileName = 'osx-' + osArch + '-tar';
break;
case 'win32':
dataFileName = 'win-' + osArch + '-exe';
break;
default:
throw new Error(`Unexpected OS '${osPlat}'`);
}
let versions: string[] = [];
let dataUrl = 'https://nodejs.org/dist/index.json';
let rest: restm.RestClient = new restm.RestClient('vsts-node-tool');
let nodeVersions: INodeVersion[] =
(await rest.get(dataUrl)).result || [];
nodeVersions.forEach((nodeVersion: INodeVersion) => {
// ensure this version supports your os and platform
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
versions.push(nodeVersion.version);
}
});
// get the latest version that matches the version spec
let version: string = evaluateVersions(versions, versionSpec);
return version;
}
before(() => {
_rest = new restm.RestClient('typed-rest-client-tests');
_restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
_restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
_queryParams = {
params: {
id: 1,
foo: 'bar'
}
};
});
before(() => {
_rest = new restm.RestClient('typed-rest-client-tests');
_restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
_restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
_queryParams = {
params: {
id: 1,
foo: 'bar'
}
};
});
before(() => {
_rest = new restm.RestClient('typed-rest-client-tests');
_restBin = new restm.RestClient('typed-rest-client-tests', 'https://httpbin.org');
_restMic = new restm.RestClient('typed-rest-client-tests', 'http://microsoft.com');
});
function getClient(): rest.RestClient {
return new rest.RestClient('github-actions-setup-gcloud');
}
async function getAvailableVersions(): Promise {
let rest: restm.RestClient = new restm.RestClient("setup-r");
let tags: IRRef[] =
(await rest.get("https://rversions.r-pkg.org/r-versions"))
.result || [];
return tags.map(tag => tag.version);
}
async function getAvailableVersions(): Promise {
let rest: restm.RestClient = new restm.RestClient("setup-r");
let tags: IRRef[] =
(await rest.get("https://rversions.r-pkg.org/r-versions"))
.result || [];
return tags.map(tag => tag.version);
}