From dab0e73adf720a7b07a830d94582a3e950cb6405 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 13 Dec 2021 08:11:59 +0530 Subject: [PATCH] Refactor addPhive in tools.ts --- dist/index.js | 15 +++++---------- src/tools.ts | 15 +++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/dist/index.js b/dist/index.js index af590123..d62841b7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -732,17 +732,12 @@ async function addPhive(data) { case /7\.2/.test(data['php_version']): data['version'] = '0.14.5'; break; + case /^latest$/.test(data['version']): + data['version'] = await getLatestVersion(data); + break; } - if (data['version'] === 'latest') { - data['version'] = await getLatestVersion(data); - } - data['domain'] = [ - data['github'], - data['repository'], - 'releases/download', - data['version'] - ].join('/'); - data['url'] = await getPharUrl(data); + data['extension'] = '-' + data['version'] + data['extension']; + data['url'] = await getUrl(data); return await addArchive(data); } exports.addPhive = addPhive; diff --git a/src/tools.ts b/src/tools.ts index 5f5915ad..9ed495cd 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -327,17 +327,12 @@ export async function addPhive(data: RS): Promise { case /7\.2/.test(data['php_version']): data['version'] = '0.14.5'; break; + case /^latest$/.test(data['version']): + data['version'] = await getLatestVersion(data); + break; } - if (data['version'] === 'latest') { - data['version'] = await getLatestVersion(data); - } - data['domain'] = [ - data['github'], - data['repository'], - 'releases/download', - data['version'] - ].join('/'); - data['url'] = await getPharUrl(data); + data['extension'] = '-' + data['version'] + data['extension']; + data['url'] = await getUrl(data); return await addArchive(data); }