mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-22 10:03:24 +01:00
Simplify if/else logic for checking wrangler versions as per review notes
This commit is contained in:
parent
06f5e60089
commit
992c58e932
1 changed files with 18 additions and 21 deletions
31
src/index.ts
31
src/index.ts
|
@ -87,6 +87,7 @@ async function installWrangler() {
|
||||||
|
|
||||||
startGroup("🔍 Checking for existing Wrangler installation");
|
startGroup("🔍 Checking for existing Wrangler installation");
|
||||||
let installedVersion = "";
|
let installedVersion = "";
|
||||||
|
let installedVersionSatisfiesRequirement = false;
|
||||||
try {
|
try {
|
||||||
const { stdout } = await getExecOutput(
|
const { stdout } = await getExecOutput(
|
||||||
packageManager.exec,
|
packageManager.exec,
|
||||||
|
@ -106,31 +107,27 @@ async function installWrangler() {
|
||||||
if (versionMatch) {
|
if (versionMatch) {
|
||||||
installedVersion = versionMatch[1];
|
installedVersion = versionMatch[1];
|
||||||
}
|
}
|
||||||
if (installedVersion) {
|
|
||||||
if (config.didUserProvideWranglerVersion) {
|
if (config.didUserProvideWranglerVersion) {
|
||||||
if (semverEq(config.WRANGLER_VERSION, installedVersion)) {
|
installedVersionSatisfiesRequirement = semverEq(
|
||||||
|
installedVersion,
|
||||||
|
config["WRANGLER_VERSION"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!config.didUserProvideWranglerVersion && installedVersion) {
|
||||||
|
info(`✅ No wrangler version specified, using pre-installed wrangler version ${installedVersion}`, true);
|
||||||
|
endGroup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (config.didUserProvideWranglerVersion && installedVersionSatisfiesRequirement) {
|
||||||
info(`✅ Using Wrangler ${installedVersion}`, true);
|
info(`✅ Using Wrangler ${installedVersion}`, true);
|
||||||
endGroup();
|
endGroup();
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
info(
|
|
||||||
`Wrangler version ${installedVersion} is not equal to the required version. Installing...`,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
info(
|
|
||||||
`✅ No wrangler version specified, using pre-installed wrangler version ${installedVersion}`,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
endGroup();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
info('⚠️ Wrangler not found or version is incompatible. Installing...', true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
debug(`Error checking Wrangler version: ${error}`);
|
debug(`Error checking Wrangler version: ${error}`);
|
||||||
info(
|
info(
|
||||||
"Wrangler not found or version is not compatible. Installing...",
|
"⚠️ Wrangler not found or version is incompatible. Installing...",
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in a new issue