Add alias latest

This commit is contained in:
Shivam Mathur
2020-10-02 14:51:40 +05:30
parent 716331904e
commit ebba1db2c3
4 changed files with 49 additions and 5 deletions

View File

@ -61,8 +61,9 @@ export async function build(
*/
export async function run(): Promise<void> {
try {
let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const version: string = await utils.parseVersion(
await utils.getInput('php-version', true)
);
const os_version: string = process.platform;
// check the os version and run the respective script

View File

@ -22,6 +22,25 @@ export async function getInput(
}
}
/**
* Function to parse PHP version.
*
* @param version
*/
export async function parseVersion(version: string): Promise<string> {
switch (version) {
case 'latest':
return '7.4';
default:
switch (true) {
case version.length > 1:
return version.slice(0, 3);
default:
return version + '.0';
}
}
}
/**
* Async foreach loop
*