Created
May 10, 2019 17:30
-
-
Save tomoima525/32b304409fdf275b549d54f8501fb800 to your computer and use it in GitHub Desktop.
semver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const formatDateToUTC = date => { | |
const month = `${date.getUTCMonth() + 1}`; | |
const day = `${date.getUTCDate()}`; | |
const hour = `${date.getUTCHours()}`; | |
const min = `${date.getUTCMinutes()}`; | |
const year = `${date.getFullYear()}`; | |
const list = [year, month, day, hour, min]; | |
return list | |
.map(v => { | |
if (v.length === 1) { | |
return `0${v}`; | |
} | |
return v; | |
}) | |
.join(''); | |
}; | |
module.exports = formatDateToUTC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const semver = require('semver'); | |
const formatDateToUTC = require('./utils/format_date_to_utc'); | |
const hoge = current => semver.inc(current, 'minor'); | |
const nextMinorVersion = current => semver.inc(current, 'minor'); | |
const nextPatchVersion = current => semver.inc(current, 'patch'); | |
// console.log('====== v', hoge('0.0.100'), nextMinorVersion('0.0.100'), nextPatchVersion('0.1.100')); | |
// console.log('====', date.getUTCDate(), date.getUTCMonth() + 1, format(date)); | |
const nextScheduledVersion = current => | |
semver.inc(current, 'prepatch', formatDateToUTC(new Date())); | |
console.log( | |
'====', | |
nextScheduledVersion('0.5.0'), | |
nextScheduledVersion('0.5.1-201905091829.0'), | |
nextPatchVersion('0.5.1-201905091829.0'), | |
nextMinorVersion('0.5.1-201905091829.0'), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment