Fix version prefix for castor

This commit is contained in:
Shivam Mathur 2023-06-23 23:28:05 +05:30
parent e40aa32c04
commit c63f07d82e
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
4 changed files with 10 additions and 44 deletions

View File

@ -539,6 +539,7 @@ describe('Tools tests', () => {
const data = getData({
tool: 'castor',
php_version: '8.1',
version_prefix: 'v',
version: version,
os: os
});

22
dist/index.js vendored
View File

@ -838,25 +838,9 @@ async function addBlackfirePlayer(data) {
}
exports.addBlackfirePlayer = addBlackfirePlayer;
async function addCastor(data) {
let filename;
switch (data['os']) {
case 'linux':
case 'darwin':
filename = 'castor.' + data['os'] + '-amd64.phar';
break;
case 'win32':
filename = 'castor.windows-amd64.phar';
break;
default:
return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error');
}
if (data['version'] === 'latest') {
data['uri'] = ['releases/latest/download', filename].join('/');
}
else {
data['uri'] = ['releases/download', 'v' + data['version'], filename].join('/');
}
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
data['url'] = await getUrl(data);
data['tool'] = 'castor';
return await addArchive(data);
}
exports.addCastor = addCastor;

View File

@ -226,7 +226,9 @@
"type": "custom-function",
"domain": "https://github.com",
"repository": "jolicode/castor",
"function": "castor"
"function": "castor",
"version_prefix": "v",
"version_parameter": "-V"
},
"composer": {
"type": "custom-function",

View File

@ -236,30 +236,9 @@ export async function addBlackfirePlayer(data: RS): Promise<string> {
* @param data
*/
export async function addCastor(data: RS): Promise<string> {
let filename: string;
switch (data['os']) {
case 'linux':
case 'darwin':
filename = 'castor.' + data['os'] + '-amd64.phar';
break;
case 'win32':
filename = 'castor.windows-amd64.phar';
break;
default:
return await utils.log(
'Platform ' + data['os'] + ' is not supported',
data['os'],
'error'
);
}
if (data['version'] === 'latest') {
data['uri'] = ['releases/latest/download', filename].join('/');
} else {
data['uri'] = ['releases/download', 'v' + data['version'], filename].join(
'/'
);
}
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
data['tool'] = 'castor.' + data['os'].replace('win32', 'windows') + '-amd64';
data['url'] = await getUrl(data);
data['tool'] = 'castor';
return await addArchive(data);
}