mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Minor refactor in utils.resolveVersion
This commit is contained in:
parent
e8d8aa3403
commit
9c411b6e2b
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -1284,23 +1284,18 @@ async function parseExtensionSource(extension, prefix) {
|
|||||||
}
|
}
|
||||||
exports.parseExtensionSource = parseExtensionSource;
|
exports.parseExtensionSource = parseExtensionSource;
|
||||||
async function resolveVersion() {
|
async function resolveVersion() {
|
||||||
let version = await getInput('php-version', false);
|
const version = await getInput('php-version', false);
|
||||||
let versionFile = await getInput('php-version-file', false);
|
|
||||||
if (version) {
|
if (version) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
if (versionFile && !fs_1.default.existsSync(versionFile)) {
|
const versionFile = (await getInput('php-version-file', false)) || '.php-version';
|
||||||
|
if (fs_1.default.existsSync(versionFile)) {
|
||||||
|
return fs_1.default.readFileSync(versionFile, 'utf8');
|
||||||
|
}
|
||||||
|
else if (versionFile !== '.php-version') {
|
||||||
throw new Error(`Could not find '${versionFile}' file.`);
|
throw new Error(`Could not find '${versionFile}' file.`);
|
||||||
}
|
}
|
||||||
versionFile ??= '.php-version';
|
return 'latest';
|
||||||
if (fs_1.default.existsSync(versionFile)) {
|
|
||||||
version = fs_1.default.readFileSync(versionFile, 'utf8');
|
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
|
||||||
}
|
|
||||||
if (!version) {
|
|
||||||
version = 'latest';
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
exports.resolveVersion = resolveVersion;
|
exports.resolveVersion = resolveVersion;
|
||||||
async function setVariable(variable, command, os) {
|
async function setVariable(variable, command, os) {
|
||||||
|
25
src/utils.ts
25
src/utils.ts
@ -427,29 +427,18 @@ export async function parseExtensionSource(
|
|||||||
* Resolve php version from input or file
|
* Resolve php version from input or file
|
||||||
*/
|
*/
|
||||||
export async function resolveVersion(): Promise<string> {
|
export async function resolveVersion(): Promise<string> {
|
||||||
let version = await getInput('php-version', false);
|
const version = await getInput('php-version', false);
|
||||||
let versionFile = await getInput('php-version-file', false);
|
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
const versionFile =
|
||||||
if (versionFile && !fs.existsSync(versionFile)) {
|
(await getInput('php-version-file', false)) || '.php-version';
|
||||||
|
if (fs.existsSync(versionFile)) {
|
||||||
|
return fs.readFileSync(versionFile, 'utf8');
|
||||||
|
} else if (versionFile !== '.php-version') {
|
||||||
throw new Error(`Could not find '${versionFile}' file.`);
|
throw new Error(`Could not find '${versionFile}' file.`);
|
||||||
}
|
}
|
||||||
|
return 'latest';
|
||||||
versionFile ??= '.php-version';
|
|
||||||
|
|
||||||
if (fs.existsSync(versionFile)) {
|
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!version) {
|
|
||||||
version = 'latest';
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user