mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
ci: update formatting tag
This commit is contained in:
@@ -21,6 +21,11 @@ describe('Format Tag', () => {
|
|||||||
test('GIVEN tag with no prefix THEN return tag', () => {
|
test('GIVEN tag with no prefix THEN return tag', () => {
|
||||||
expect(formatTag('13.5.1')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.5.1' });
|
expect(formatTag('13.5.1')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.5.1' });
|
||||||
expect(formatTag('13.7.0')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.7.0' });
|
expect(formatTag('13.7.0')).toEqual({ isSubpackage: false, package: 'discord.js', semver: '13.7.0' });
|
||||||
|
expect(formatTag('create-discord-bot@1.0.0')).toEqual({
|
||||||
|
isSubpackage: false,
|
||||||
|
package: 'create-discord-bot',
|
||||||
|
semver: '1.0.0',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN no or invalid tag THEN return null', () => {
|
test('GIVEN no or invalid tag THEN return null', () => {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ inputs:
|
|||||||
description: 'The input tag'
|
description: 'The input tag'
|
||||||
required: true
|
required: true
|
||||||
outputs:
|
outputs:
|
||||||
|
subpackage:
|
||||||
|
description: 'Whether this tag is a subpackage tag'
|
||||||
package:
|
package:
|
||||||
description: 'The package string that was extracted from this tag'
|
description: 'The package string that was extracted from this tag'
|
||||||
semver:
|
semver:
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
export function formatTag(tag: string) {
|
export function formatTag(tag: string) {
|
||||||
// eslint-disable-next-line unicorn/no-unsafe-regex, prefer-named-capture-group
|
// eslint-disable-next-line unicorn/no-unsafe-regex
|
||||||
const parsed = /(^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
|
const parsed = /(?:^@.*\/(?<package>.*)@v?)?(?<semver>\d+.\d+.\d+)-?.*/.exec(tag);
|
||||||
|
const parsedPackage = /(?<package>.*)@v?-?.*/.exec(tag);
|
||||||
|
|
||||||
if (parsed?.groups) {
|
if (parsed?.groups) {
|
||||||
|
const isSubpackage = typeof parsed.groups.package === 'string';
|
||||||
|
const pkg = isSubpackage ? parsed.groups.package : parsedPackage?.groups?.package ?? 'discord.js';
|
||||||
|
const semver = parsed.groups.semver;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isSubpackage: typeof parsed.groups.package === 'string',
|
isSubpackage,
|
||||||
package: parsed.groups.package ?? 'discord.js',
|
package: pkg,
|
||||||
semver: parsed.groups.semver,
|
semver,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user