Skip to content

Commit

Permalink
Fix (release-tools): The getNpmTagFromVersion() function handles in…
Browse files Browse the repository at this point in the history
…ternal releases correctly.
  • Loading branch information
pomek committed Oct 17, 2024
1 parent 53aac3d commit baad1a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ export default function getNpmTagFromVersion( version ) {
return 'nightly';
}

if ( versionTag.startsWith( 'internal' ) ) {
return 'internal';
}

return versionTag;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
* For licensing, see LICENSE.md.
*/

import { describe, it, expect, vi } from 'vitest';
import semver from 'semver';
import { describe, it, expect } from 'vitest';

import getNpmTagFromVersion from '../../lib/utils/getnpmtagfromversion.js';

vi.mock( 'semver' );

describe( 'getNpmTagFromVersion()', () => {
it( 'should return "latest" when processing a X.Y.Z version', () => {
expect( getNpmTagFromVersion( '1.0.0' ) ).to.equal( 'latest' );
Expand All @@ -18,16 +15,16 @@ describe( 'getNpmTagFromVersion()', () => {
} );

it( 'should return "alpha" when processing a X.Y.Z-alpha.X version', () => {
vi.mocked( semver.prerelease ).mockReturnValue( [ 'alpha', 0 ] );

expect( getNpmTagFromVersion( '1.0.0-alpha.0' ) ).to.equal( 'alpha' );
expect( getNpmTagFromVersion( '2.1.0-alpha.0' ) ).to.equal( 'alpha' );
expect( getNpmTagFromVersion( '3.2.1-alpha.0' ) ).to.equal( 'alpha' );
} );

it( 'should return "nightly" when processing a 0.0.0-nightly-YYYYMMDD.X version', () => {
vi.mocked( semver.prerelease ).mockReturnValue( [ 'nightly', 0 ] );

expect( getNpmTagFromVersion( '0.0.0-nightly-20230517.0' ) ).to.equal( 'nightly' );
} );

it( 'should return "internal" when processing a 0.0.0-internal-YYYYMMDD.X version', () => {
expect( getNpmTagFromVersion( '0.0.0-internal-20230517.0' ) ).to.equal( 'internal' );
} );
} );

0 comments on commit baad1a6

Please sign in to comment.