From 556bde9119cd6fe844fb40a8b50f511cd0aa2629 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 25 Sep 2021 17:02:46 +0800 Subject: [PATCH] fix: script bump use zx --- scripts/bump-version.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/bump-version.js b/scripts/bump-version.js index 00d6de60..9802c5de 100644 --- a/scripts/bump-version.js +++ b/scripts/bump-version.js @@ -1,9 +1,9 @@ const { readFileSync, writeFileSync } = require('fs') const { join } = require('path') -const { chalk } = require('zx') +const { chalk, $ } = require('zx') + const inquirer = require('inquirer') const semver = require('semver') -const { execSync } = require('child_process') const PKG_PATH = join(process.cwd(), './package.json') const PKG = JSON.parse(readFileSync(PKG_PATH)) @@ -31,16 +31,9 @@ function generateReleaseTypes(currentVersion, types, pried = 'alpha') { }) } -function execCmd(cmds) { +async function execCmd(cmds) { for (const cmd of cmds) { - console.log(chalk.green(`Running: ${cmd}`)) - try { - execSync(cmd, { encoding: 'utf8' }) - } catch (e) { - console.log(chalk.red(`Error running command: ${cmd}`)) - console.log(chalk.yellow(`${e.stderr}`)) - return - } + await $([cmd]) } } @@ -57,11 +50,11 @@ async function main() { PKG.version = newVersion console.log(chalk.green('Running before hooks.')) - execCmd(beforeHooks) + await execCmd(beforeHooks) writeFileSync(PKG_PATH, JSON.stringify(PKG, null, 2)) console.log(chalk.green('Running after hooks.')) - execCmd(afterHooks) + await execCmd(afterHooks) } main()