diff --git a/packages/semver/package.json b/packages/semver/package.json index 2bbbd61d7..d0b721cd3 100644 --- a/packages/semver/package.json +++ b/packages/semver/package.json @@ -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" }, diff --git a/packages/semver/src/executors/version/utils/get-last-version.spec.ts b/packages/semver/src/executors/version/utils/get-last-version.spec.ts index 2c6ef8c0b..d419482a1 100644 --- a/packages/semver/src/executors/version/utils/get-last-version.spec.ts +++ b/packages/semver/src/executors/version/utils/get-last-version.spec.ts @@ -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 () => { diff --git a/packages/semver/src/executors/version/utils/get-last-version.ts b/packages/semver/src/executors/version/utils/get-last-version.ts index cf1e17a06..ef73ecb9c 100644 --- a/packages/semver/src/executors/version/utils/get-last-version.ts +++ b/packages/semver/src/executors/version/utils/get-last-version.ts @@ -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({ @@ -15,10 +13,8 @@ export function getLastVersion({ includePrerelease?: boolean; preid?: string; }): Observable { - return from( - promisify(gitSemverTags)({ tagPrefix }) as Promise, - ).pipe( - switchMap((tags: string[]) => { + return from(gitSemverTags({ tagPrefix }) as Promise).pipe( + switchMap((tags) => { const versions = tags .map((tag) => tag.substring(tagPrefix.length)) .filter((v) => { diff --git a/yarn.lock b/yarn.lock index 7df60e44d..630dde044 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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: @@ -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: