mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
Add alias latest
This commit is contained in:
parent
716331904e
commit
ebba1db2c3
@ -26,6 +26,12 @@ describe('Utils tests', () => {
|
||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||
});
|
||||
|
||||
it('checking parseVersion', async () => {
|
||||
expect(await utils.parseVersion('7')).toBe('7.0');
|
||||
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
||||
expect(await utils.parseVersion('latest')).toBe('7.4');
|
||||
});
|
||||
|
||||
it('checking asyncForEach', async () => {
|
||||
const array: Array<string> = ['a', 'b', 'c'];
|
||||
let concat = '';
|
||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@ -1097,7 +1097,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0;
|
||||
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.getInput = void 0;
|
||||
const fs = __importStar(__webpack_require__(747));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
const core = __importStar(__webpack_require__(470));
|
||||
@ -1118,6 +1118,25 @@ async function getInput(name, mandatory) {
|
||||
}
|
||||
}
|
||||
exports.getInput = getInput;
|
||||
/**
|
||||
* Function to parse PHP version.
|
||||
*
|
||||
* @param version
|
||||
*/
|
||||
async function parseVersion(version) {
|
||||
switch (version) {
|
||||
case 'latest':
|
||||
return '7.4';
|
||||
default:
|
||||
switch (true) {
|
||||
case version.length > 1:
|
||||
return version.slice(0, 3);
|
||||
default:
|
||||
return version + '.0';
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.parseVersion = parseVersion;
|
||||
/**
|
||||
* Async foreach loop
|
||||
*
|
||||
@ -2567,8 +2586,7 @@ exports.build = build;
|
||||
*/
|
||||
async function run() {
|
||||
try {
|
||||
let version = await utils.getInput('php-version', true);
|
||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
||||
const os_version = process.platform;
|
||||
// check the os version and run the respective script
|
||||
let script_path = '';
|
||||
|
@ -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
|
||||
|
19
src/utils.ts
19
src/utils.ts
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user