diff --git a/action.yml b/action.yml index 7af8026..1258333 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ outputs: new_version: description: The bumped calver version. runs: - using: node12 + using: node16 main: dist/index.js branding: icon: bookmark diff --git a/dist/index.js b/dist/index.js index f01ddf0..f1a33f1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1565,12 +1565,7 @@ class Calver { this.year = year; this.month = month; this.index = Number(index); - if (currentVersion.startsWith('v')) { - this.hasVPrefix = true; - } - else { - this.hasVPrefix = false; - } + this.hasVPrefix = currentVersion.startsWith('v') ? true : false; } toString() { let output = `${this.year}.${this.month}.${this.index}`; @@ -1586,8 +1581,8 @@ class Calver { this.index += 1; } else { - this.year = String('00' + now.getFullYear()).slice(-2); - this.month = String('00' + now.getMonth() + 1).slice(-2); + this.year = String(now.getFullYear()).slice(-2); + this.month = String('0' + (Number(now.getMonth()) + 1)).slice(-2); this.index = 0; } return this; diff --git a/src/calver.ts b/src/calver.ts index d191b45..bf2c85b 100644 --- a/src/calver.ts +++ b/src/calver.ts @@ -19,11 +19,7 @@ export class Calver { this.year = year; this.month = month; this.index = Number(index); - if (currentVersion.startsWith('v')) { - this.hasVPrefix = true; - } else { - this.hasVPrefix = false; - } + this.hasVPrefix = currentVersion.startsWith('v') ? true : false; } toString(): string { @@ -42,8 +38,8 @@ export class Calver { ) { this.index += 1; } else { - this.year = String('00' + now.getFullYear()).slice(-2); - this.month = String('00' + (now.getMonth() + 1)).slice(-2); + this.year = String(now.getFullYear()).slice(-2); + this.month = String('0' + (Number(now.getMonth()) + 1)).slice(-2); this.index = 0; } return this;