Skip to content

Commit

Permalink
Address CR comments - check for an exact wrangler version match
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiRishi committed Mar 2, 2024
1 parent 3408e5a commit 1dadfd3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
setOutput,
} from "@actions/core";
import { getExecOutput } from "@actions/exec";
import semverGt from "semver/functions/gt";
import semverEq from "semver/functions/eq";
import { exec, execShell } from "./exec";
import { checkWorkingDirectory, semverCompare } from "./utils";
import { getPackageManager } from "./packageManagers";
Expand All @@ -23,6 +23,7 @@ const DEFAULT_WRANGLER_VERSION = "3.13.2";
*/
const config = {
WRANGLER_VERSION: getInput("wranglerVersion") || DEFAULT_WRANGLER_VERSION,
didUserProvideWranglerVersion: Boolean(getInput("wranglerVersion")),
secrets: getMultilineInput("secrets"),
workingDirectory: checkWorkingDirectory(getInput("workingDirectory")),
CLOUDFLARE_API_TOKEN: getInput("apiToken"),
Expand Down Expand Up @@ -102,13 +103,22 @@ async function installWrangler() {
);
}
installedVersion = versionMatch[1];
if (semverGt(config["WRANGLER_VERSION"], installedVersion)) {
if (config.didUserProvideWranglerVersion) {
if (semverEq(config.WRANGLER_VERSION, installedVersion)) {
info(`✅ Using Wrangler ${installedVersion}`, true);
endGroup();
return;
} else {
info(
`Wrangler version ${installedVersion} is not equal to the required version. Installing...`,
true,
);
}
} else {
info(
`Wrangler version ${installedVersion} is less than required. Installing...`,
`✅ No wrangler version specified, using pre-installed wrangler version ${installedVersion}`,
true,
);
} else {
info(`✅ Using Wrangler ${installedVersion}`, true);
endGroup();
return;
}
Expand Down

0 comments on commit 1dadfd3

Please sign in to comment.