Skip to content

Commit

Permalink
feat(use) - support "stable" as bvm use argument (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiladShoham authored Jan 15, 2024
1 parent 82facd2 commit 93eb0ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions teambit.bvm/commands/use/use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export class UseCmd implements CommandModule {
})
.example('$0 use', 'show currently used version of bit')
.example('$0 use 1.7.5', 'switch to version 1.7.5 of bit')
.example('$0 use stable', 'switch to latest installed stable version')
.example('$0 use latest', 'switch to latest installed version')
return yargs;
}
async handler(args) {
Expand Down
7 changes: 7 additions & 0 deletions teambit.bvm/link/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export async function linkOne(linkName: string, version: string | undefined, opt
const localLatest = (await listLocal()).latest();
concreteVersion = localLatest.version;
}
if (concreteVersion === 'stable'){
const localStable = (await listLocal()).stable();
if (!localStable){
throw new BvmError(`no stable version found installed`);
}
concreteVersion = localStable.version;
}
const {versionDir, exists} = config.getSpecificVersionDir(concreteVersion, true);
if (!exists){
throw new BvmError(`version ${concreteVersion} is not installed`);
Expand Down
5 changes: 5 additions & 0 deletions teambit.bvm/list/version-list/version-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class VersionList {
return sorted.entries[0];
}

stable(): Version | undefined {
const sorted = this.sortBySemver('desc');
return sorted.entries.find(version => version.releaseType === 'stable');
}

find(version: string): Version | undefined {
return this.entries.find(entry => entry.version === version);
}
Expand Down

0 comments on commit 93eb0ff

Please sign in to comment.