2018-06-05 16:37:52 -03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
const chalk = require("chalk");
|
|
|
|
|
const semver = require("semver");
|
|
|
|
|
|
2020-03-21 22:07:52 +02:00
|
|
|
module.exports = async function ({ version, previousVersion }) {
|
2018-06-05 16:37:52 -03:00
|
|
|
if (!semver.valid(version)) {
|
2020-01-14 20:31:27 +02:00
|
|
|
throw new Error("Invalid version specified");
|
2018-06-05 16:37:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!semver.gt(version, previousVersion)) {
|
2019-11-17 18:36:21 +08:00
|
|
|
throw new Error(
|
|
|
|
|
`Version ${chalk.yellow(version)} has already been published`
|
|
|
|
|
);
|
2018-06-05 16:37:52 -03:00
|
|
|
}
|
|
|
|
|
};
|