Skip to content

Commit 20f547a

Browse files
Merge pull request #330 from technote-space/release/next-v4.2.4
release: v4.2.5
2 parents 470f1a6 + 6248a78 commit 20f547a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

__tests__/utils1.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ describe('normalizeVersion', () => {
214214
expect(normalizeVersion('abc')).toBeUndefined();
215215
expect(normalizeVersion('test/v1.2.3')).toBeUndefined();
216216
});
217+
218+
it('should return fallback', () => {
219+
expect(normalizeVersion('', {fallback: ''})).toBe('');
220+
expect(normalizeVersion('', {fallback: null})).toBe(null);
221+
expect(normalizeVersion('', {fallback: 'abc'})).toBe('abc');
222+
});
217223
});
218224

219225
describe('isValidSemanticVersioning', () => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "4.2.4",
3+
"version": "4.2.5",
44
"description": "Helper for GitHub Action.",
55
"keywords": [
66
"github",

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export const parseVersion = (version: string, options?: { fill?: boolean; cut?:
6363
};
6464
};
6565

66-
export const normalizeVersion = (version: string, options?: { fill?: boolean; cut?: boolean; slice?: number; length?: number; onlyCore?: boolean; }): string | undefined => {
66+
export const normalizeVersion = (version: string, options?: { fill?: boolean; cut?: boolean; slice?: number; length?: number; onlyCore?: boolean; fallback?: string | null }): string | undefined | null => {
6767
const parsed = parseVersion(version, options);
6868
if (!parsed) {
69-
return undefined;
69+
return options?.fallback;
7070
}
7171

7272
if (options?.onlyCore) {

0 commit comments

Comments
 (0)