Skip to content

Commit

Permalink
Coerce cli version with semver to allow for prerelease tags (#4291)
Browse files Browse the repository at this point in the history
  • Loading branch information
gantoine committed Mar 30, 2022
1 parent f01f996 commit 4fbc8d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cli/src/lib/cacheRepoUtils.js
Expand Up @@ -141,7 +141,12 @@ export async function verifyCLIVersion(): Promise<void> {
const thisCLIPkgJsonPath = path.join(__dirname, '..', '..', 'package.json');
const thisCLIPkgJson = await fs.readJson(thisCLIPkgJsonPath);
const thisCLIVersion = thisCLIPkgJson.version;
if (!semver.satisfies(thisCLIVersion, compatibleCLIRange)) {
if (
!semver.satisfies(
semver.coerce(thisCLIVersion) ?? thisCLIVersion,
compatibleCLIRange,
)
) {
throw new Error(
`Please upgrade your flow-typed CLI! This CLI is version ` +
`${thisCLIVersion}, but the latest flow-typed definitions are only ` +
Expand Down
7 changes: 6 additions & 1 deletion cli/src/lib/libDefs.js
Expand Up @@ -419,7 +419,12 @@ async function verifyCLIVersion(defsDirPath) {
}
const minCLIVersion = metadata.compatibleCLIRange;
const thisCLIVersion = require('../../package.json').version;
if (!semver.satisfies(thisCLIVersion, minCLIVersion)) {
if (
!semver.satisfies(
semver.coerce(thisCLIVersion) ?? thisCLIVersion,
minCLIVersion,
)
) {
throw new Error(
`Please upgrade your CLI version! This CLI is version ` +
`${thisCLIVersion}, but the latest flow-typed definitions are only ` +
Expand Down

0 comments on commit 4fbc8d7

Please sign in to comment.