Comparing version 7.6.4 to 7.7.0
{ | ||
"name": "np", | ||
"version": "7.6.4", | ||
"version": "7.7.0", | ||
"description": "A better `npm publish`", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -62,11 +62,3 @@ 'use strict'; | ||
task: () => { | ||
if (!version.isValidInput(input)) { | ||
throw new Error(`Version should be either ${version.SEMVER_INCREMENTS.join(', ')}, or a valid semver version.`); | ||
} | ||
newVersion = version(pkg.version).getNewVersionFrom(input); | ||
if (version(pkg.version).isLowerThanOrEqualTo(newVersion)) { | ||
throw new Error(`New version \`${newVersion}\` should be higher than current version \`${pkg.version}\``); | ||
} | ||
newVersion = version.getAndValidateNewVersionFrom(input, pkg.version); | ||
} | ||
@@ -73,0 +65,0 @@ }, |
@@ -94,3 +94,3 @@ 'use strict'; | ||
if (newFiles.firstTime.length > 0) { | ||
messages.push(`The following new files will be published the first time:\n${chalk.reset(newFiles.firstTime.map(path => `- ${path}`).join('\n'))}`); | ||
messages.push(`The following new files will be published for the first time:\n${chalk.reset(newFiles.firstTime.map(path => `- ${path}`).join('\n'))}`); | ||
} | ||
@@ -136,3 +136,6 @@ | ||
} else { | ||
console.log(`\nPublish a new version of ${chalk.bold.magenta(pkg.name)} ${chalk.dim(`(current: ${oldVersion})`)}\n`); | ||
const newVersion = options.version ? version.getAndValidateNewVersionFrom(options.version, oldVersion) : undefined; | ||
const versionText = chalk.dim(`(current: ${oldVersion}${newVersion ? `, next: ${prettyVersionDiff(oldVersion, newVersion)}` : ''}${chalk.dim(')')}`); | ||
console.log(`\nPublish a new version of ${chalk.bold.magenta(pkg.name)} ${versionText}\n`); | ||
} | ||
@@ -139,0 +142,0 @@ |
@@ -23,3 +23,3 @@ 'use strict'; | ||
if (!module.exports.isValidInput(input)) { | ||
throw new Error(`Version should be either ${module.exports.SEMVER_INCREMENTS.join(', ')} or a valid semver version.`); | ||
throw new Error(`Version should be either ${module.exports.SEMVER_INCREMENTS.join(', ')}, or a valid semver version.`); | ||
} | ||
@@ -68,1 +68,11 @@ | ||
}; | ||
module.exports.getAndValidateNewVersionFrom = (input, version) => { | ||
const newVersion = module.exports(version).getNewVersionFrom(input); | ||
if (module.exports(version).isLowerThanOrEqualTo(newVersion)) { | ||
throw new Error(`New version \`${newVersion}\` should be higher than current version \`${version}\``); | ||
} | ||
return newVersion; | ||
}; |
66054
1547