Skip to content

Commit

Permalink
fix: bsl date is incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
gempain committed Dec 12, 2020
1 parent 4df4c34 commit 1dd61cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@
"semantic-release": "^17.2.3",
"ts-jest": "^26.4.4",
"typescript": "^4.0.5"
}
},
"dependencies": {}
}
2 changes: 1 addition & 1 deletion src/handlers/bsl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('bsl', () => {
const date = new Date();
console.log(updatedLicense);
expect(updatedLicense.indexOf('MyApp 1.1.0-beta.2') !== -1).toBeTruthy();
expect(updatedLicense.indexOf(`Change Date: ${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`) !== -1).toBeTruthy();
expect(updatedLicense.indexOf(`Change Date: ${date.getFullYear() + 4}-${date.getMonth() + 1}-${date.getDate()}`) !== -1).toBeTruthy();
expect(updatedLicense.indexOf(`(c) ${date.getFullYear()} My Company`) !== -1).toBeTruthy();
});

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/bsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function bsl(content: string, context: Context): string {
))
.replace(/(Change Date.*)(\d{4}-\d{2}-\d{2})/, (full, part1) => {
const today = new Date();
const newDate = `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`;
const newDate = `${today.getFullYear() + 4}-${today.getMonth() + 1}-${today.getDate()}`;
return `${part1}${newDate}`;
})
.replace(/(The Licensed Work is \(c\) )(\d{4})/, (full, part1) => `${part1}${new Date().getFullYear()}`);
Expand Down

0 comments on commit 1dd61cf

Please sign in to comment.