Skip to content

Commit

Permalink
fix(semver): bump git-semver-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
edbzn committed Oct 22, 2023
1 parent 9e0ddf9 commit e1b9e05
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions packages/semver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"conventional-changelog-conventionalcommits": "^7.0.2",
"conventional-recommended-bump": "^7.0.0",
"detect-indent": "6.1.0",
"git-semver-tags": "^7.0.1",
"inquirer": "8.2.6",
"rxjs": "7.8.1"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import * as gitSemverTags from 'git-semver-tags';
import { lastValueFrom } from 'rxjs';
import { callbackify } from 'util';

import { getLastVersion } from './get-last-version';

jest.mock('git-semver-tags', () => jest.fn());
jest.mock('./project');
jest.mock('git-semver-tags');

const tagPrefix = 'my-lib-';

describe(getLastVersion.name, () => {
let mockGitSemverTags: jest.Mock;
const mockGitSemverTags: jest.Mock = gitSemverTags;

beforeEach(() => {
mockGitSemverTags = jest.fn();
(gitSemverTags as jest.Mock).mockImplementation(
callbackify(mockGitSemverTags),
);
mockGitSemverTags.mockReset();
});

it('should compute current version from previous semver tag', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as gitSemverTags from 'git-semver-tags';
import { from, of, throwError } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import * as semver from 'semver';
import { promisify } from 'util';

import type { Observable } from 'rxjs';

export function getLastVersion({
Expand All @@ -15,10 +13,8 @@ export function getLastVersion({
includePrerelease?: boolean;
preid?: string;
}): Observable<string> {
return from(
promisify(gitSemverTags)({ tagPrefix }) as Promise<string[]>,
).pipe(
switchMap((tags: string[]) => {
return from(gitSemverTags({ tagPrefix }) as Promise<string[]>).pipe(
switchMap((tags) => {
const versions = tags
.map((tag) => tag.substring(tagPrefix.length))
.filter((v) => {
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,7 @@ __metadata:
conventional-changelog-conventionalcommits: ^7.0.2
conventional-recommended-bump: ^7.0.0
detect-indent: 6.1.0
git-semver-tags: ^7.0.1
inquirer: 8.2.6
rxjs: 7.8.1
peerDependencies:
Expand Down Expand Up @@ -4997,7 +4998,7 @@ __metadata:
languageName: node
linkType: hard

"git-semver-tags@npm:^7.0.0":
"git-semver-tags@npm:^7.0.0, git-semver-tags@npm:^7.0.1":
version: 7.0.1
resolution: "git-semver-tags@npm:7.0.1"
dependencies:
Expand Down

0 comments on commit e1b9e05

Please sign in to comment.