Skip to content

Commit

Permalink
Minor refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 13, 2018
1 parent ec3e010 commit 7e2e9e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/prompt.js
Expand Up @@ -62,7 +62,7 @@ const prompts = {
},
release: {
type: 'confirm',
message: () => `Create a release on GitHub (${format(options.github.releaseName)})?`
message: context => `Create a release on GitHub (${format(context.github.releaseName)})?`
},
publish: {
type: 'confirm',
Expand Down
20 changes: 10 additions & 10 deletions lib/version.js
Expand Up @@ -45,32 +45,32 @@ const parse = async options => {
const isPreReleaseContinuation = isPreRelease && !!semver.prerelease(latestVersion);
const isValidType = _.includes(allReleaseTypes, normalizedType);

const result = {
latestVersion,
version: null
};
let version = null;

switch (true) {
case isValidIncrement:
result.version = increment;
version = increment;
break;
case isPreReleaseContinuation:
result.version = semver.inc(latestVersion, 'prerelease', preReleaseId);
version = semver.inc(latestVersion, 'prerelease', preReleaseId);
break;
case isValidType:
result.version = semver.inc(latestVersion, normalizedType, preReleaseId);
version = semver.inc(latestVersion, normalizedType, preReleaseId);
break;
default: {
const coercedVersion = !isValid(increment) && semver.coerce(increment);
if (coercedVersion) {
result.version = coercedVersion.toString();
warn(`Coerced invalid semver version "${increment}" into "${result.version}".`);
version = coercedVersion.toString();
warn(`Coerced invalid semver version "${increment}" into "${version}".`);
}
break;
}
}

return result;
return {
latestVersion,
version
};
};

module.exports = {
Expand Down

0 comments on commit 7e2e9e7

Please sign in to comment.