Skip to content

Commit

Permalink
fix: better semver parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Van Camp committed Jun 20, 2023
1 parent dc19836 commit 61a0e8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"node-fetch": "^2.0.0",
"npm-package-arg": "6.1.0",
"rimraf": "2.6.3",
"semver": "5.6.0",
"semver": "5.7.0",
"tar": "^6.1.13",
"tslib": "1.9.3"
},
Expand Down
7 changes: 5 additions & 2 deletions src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { execSync } from 'child_process';
import npa from 'npm-package-arg';
import path from 'path';
import util from '../lib/util';
import semver from 'semver';
import semver, { SemVer } from 'semver';
import chalk from 'chalk';
import fetchTags from '../lib/fetch-tags';
import { Command } from 'commander';
Expand Down Expand Up @@ -70,7 +70,10 @@ function action(repo: string, options: { dev: boolean }) {
let target;
try {
tags = fetchTags(repoUrl);
target = semver.maxSatisfying(tags, range);
target = semver.maxSatisfying(
tags.map((tag) => semver.coerce(tag)).filter((coercedTag): coercedTag is SemVer => Boolean(coercedTag)),
range,
);
process.stdout.write(chalk.green('done!') + os.EOL);
} catch (e) {
/* istanbul ignore next */
Expand Down

0 comments on commit 61a0e8c

Please sign in to comment.