Skip to content

Commit db7e2b8

Browse files
committed
More gracefully handing a package without any versions.
1 parent 248d18e commit db7e2b8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

apps/rush-lib/src/scripts/install-run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ function resolvePackageVersion({ name, version }: IPackageSpecifier): string {
6565
{ stdio: [] }
6666
).toString();
6767
const versionLines: string[] = npmViewVersionOutput.split('\n').filter((line) => !!line);
68-
const latestVersion: string = versionLines[versionLines.length - 1];
68+
const latestVersion: string | undefined = versionLines[versionLines.length - 1];
69+
if (!latestVersion) {
70+
throw new Error('No versions found for the specified version range.');
71+
}
72+
6973
const versionMatches: string[] | null = latestVersion.match(/^.+\s\'(.+)\'$/);
7074
if (!versionMatches) {
7175
throw new Error(`Invalid npm output ${latestVersion}`);

0 commit comments

Comments
 (0)