Skip to content

Commit

Permalink
feat: use human readable timestamp for versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiphe committed Aug 4, 2022
1 parent e9215c2 commit a1d8016
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/getNextVersion.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
const getNextVersionOrigin = require('semantic-release/lib/get-next-version');

module.exports = function getNextVersion({ logger, nextRelease, ...rest }) {
const now = Date.now();
const timestampToVersion = (v) => v.replace(/\.[0-9]+$/, `.${now}`);
const now = new Date();
const humanReadableTimestamp = `${String(now.getFullYear()).substring(
2,
)}${String(now.getMonth() + 1).padStart(2, '0')}${String(
now.getDate(),
).padStart(2, '0')}${String(now.getHours()).padStart(2, '0')}${String(
now.getMinutes(),
).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;

const timestampToVersion = (v) =>
v.replace(/\.[0-9]+$/, `.${humanReadableTimestamp}`);
const version = getNextVersionOrigin({
...rest,
nextRelease,
Expand Down

0 comments on commit a1d8016

Please sign in to comment.