From 61bf2dacd3454f2ee0e06bb7cc07d5e3c7c231ad Mon Sep 17 00:00:00 2001 From: winixt Date: Mon, 16 May 2022 17:46:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/release.mjs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/release.mjs b/scripts/release.mjs index 053363e2..7ef8fd34 100644 --- a/scripts/release.mjs +++ b/scripts/release.mjs @@ -13,12 +13,15 @@ import buildConfig from '../build.config.js'; const { prompt } = enquirer; const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); -const { preid: preId, dry: isDryRun, tag: releaseTag } = minimist(process.argv.slice(2)); +const { preid, dry: isDryRun, tag: releaseTag } = minimist(process.argv.slice(2)); const packages = buildConfig.pkgs; -const versionIncrements = ['patch', 'minor', 'major', ...(preId ? ['prepatch', 'preminor', 'premajor', 'prerelease'] : [])]; +const versionIncrements = ['patch', 'minor', 'major', 'prepatch', 'preminor', 'premajor', 'prerelease']; -const incVersion = (version, i) => semver.inc(version, i, preId); +const incVersion = (version, i) => { + const preId = preid || semver.prerelease(version)[0] || 'alpha'; + return semver.inc(version, i, preId); +}; const run = (bin, args, opts = {}) => execa(bin, args, { stdio: 'inherit', ...opts }); const dryRun = (bin, args, opts = {}) => console.log(chalk.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts); const runIfNotDry = isDryRun ? dryRun : run; @@ -27,16 +30,7 @@ const step = (msg) => console.log(chalk.cyan(msg)); // eslint-disable-next-line no-shadow async function publishPackage(pkg, runIfNotDry) { - let _releaseTag; - if (releaseTag) { - _releaseTag = releaseTag; - } else if (pkg.newVersion.includes('alpha')) { - _releaseTag = 'alpha'; - } else if (pkg.newVersion.includes('beta')) { - _releaseTag = 'beta'; - } else if (pkg.newVersion.includes('rc')) { - _releaseTag = 'rc'; - } + const _releaseTag = releaseTag || 'next'; step(`Publishing ${pkg.name}...`); try {