Skip to content

Commit

Permalink
Allow overriding Buf version in PATH
Browse files Browse the repository at this point in the history
This avoids requiring the version of Buf found in the PATH to match the
resolved. Fallsback to installing the specified in the toolcache.
  • Loading branch information
emcfarlane committed Oct 8, 2024
1 parent 275c46d commit f13b5a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
11 changes: 4 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45508,14 +45508,11 @@ async function installBuf(github, versionInput) {
silent: true,
});
const version = bufVersion.stdout.trim();
core.info(`Using buf (${version}) found in $PATH`);
if (!semver.satisfies(version, requiredVersion)) {
throw new Error(`The version of buf (${version}) does not satisfy the required version (${requiredVersion})`);
if (semver.satisfies(version, requiredVersion) &&
(resolvedVersion == "" || semver.eq(version, resolvedVersion))) {
core.info(`Using buf (${version}) found in $PATH`);
return [binName, version];
}
if (resolvedVersion != "" && !semver.eq(version, resolvedVersion)) {
throw new Error(`The version of buf (${version}) does not equal the resolved version (${resolvedVersion})`);
}
return [binName, version];
}
if (resolvedVersion === "") {
resolvedVersion = await latestVersion(github);
Expand Down
17 changes: 6 additions & 11 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ export async function installBuf(
silent: true,
});
const version = bufVersion.stdout.trim();
core.info(`Using buf (${version}) found in $PATH`);
if (!semver.satisfies(version, requiredVersion)) {
throw new Error(
`The version of buf (${version}) does not satisfy the required version (${requiredVersion})`,
);
if (
semver.satisfies(version, requiredVersion) &&
(resolvedVersion == "" || semver.eq(version, resolvedVersion))
) {
core.info(`Using buf (${version}) found in $PATH`);
return [binName, version];
}
if (resolvedVersion != "" && !semver.eq(version, resolvedVersion)) {
throw new Error(
`The version of buf (${version}) does not equal the resolved version (${resolvedVersion})`,
);
}
return [binName, version];
}
if (resolvedVersion === "") {
resolvedVersion = await latestVersion(github);
Expand Down

0 comments on commit f13b5a9

Please sign in to comment.