mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 03:41:06 +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;
|
||||
async function resolveVersion() {
|
||||
let version = await getInput('php-version', false);
|
||||
let versionFile = await getInput('php-version-file', false);
|
||||
const version = await getInput('php-version', false);
|
||||
if (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.`);
|
||||
}
|
||||
versionFile ??= '.php-version';
|
||||
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;
|
||||
return 'latest';
|
||||
}
|
||||
exports.resolveVersion = resolveVersion;
|
||||
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
|
||||
*/
|
||||
export async function resolveVersion(): Promise<string> {
|
||||
let version = await getInput('php-version', false);
|
||||
let versionFile = await getInput('php-version-file', false);
|
||||
|
||||
const version = await getInput('php-version', false);
|
||||
if (version) {
|
||||
return version;
|
||||
}
|
||||
|
||||
if (versionFile && !fs.existsSync(versionFile)) {
|
||||
const 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.`);
|
||||
}
|
||||
|
||||
versionFile ??= '.php-version';
|
||||
|
||||
if (fs.existsSync(versionFile)) {
|
||||
version = fs.readFileSync(versionFile, 'utf8');
|
||||
core.info(`Resolved ${versionFile} as ${version}`);
|
||||
}
|
||||
|
||||
if (!version) {
|
||||
version = 'latest';
|
||||
}
|
||||
|
||||
return version;
|
||||
return 'latest';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user