Skip to content

Commit

Permalink
Try to coerce provided increment into valid semver version
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 10, 2018
1 parent ab4c1e7 commit 3abbc73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/config.js
Expand Up @@ -72,7 +72,10 @@ class Config {
parseCliArguments(args) {
const cli = parseArgs(args, {
boolean: true,
alias: aliases
alias: aliases,
configuration: {
'parse-numbers': false
}
});
cli.increment = cli._[0] || cli.i;
return this.parsePreReleaseArgument(cli);
Expand Down
12 changes: 12 additions & 0 deletions lib/version.js
Expand Up @@ -85,6 +85,18 @@ const parse = async options => {
}
}

if (!isValid(increment)) {
const coercedVersion = semver.coerce(increment);
if (coercedVersion) {
const version = coercedVersion.toString();
warn(`Coerced invalid semver version "${increment}" into "${version}".`);
return {
latestVersion,
version
};
}
}

return {
latestVersion,
version: null
Expand Down

0 comments on commit 3abbc73

Please sign in to comment.