Skip to content

Commit

Permalink
更新代码
Browse files Browse the repository at this point in the history
  • Loading branch information
biaov committed Oct 11, 2023
1 parent a3c14b2 commit ebb66f8
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/commander/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ import { gitCmds, buildCmds } from './cmds'

const { iconError, iconSuccess, success, info, error, warning } = log

/**
* 执行命令
*/
const execCommand = (cmd: string) => {
info(`开始执行 ${chalk.cyanBright(cmd)} 命令`)
const spinner = ora({ text: '正在执行命令中...', color: 'yellow' })
spinner.start()
execSync(cmd, { cwd: process.cwd() })
spinner.succeed(`${chalk.green(cmd)} 命令执行成功`)
info()
}

/**
* 简化 git 提交命令
*/
export const simplifyGit = async (desc = '更新代码') => {
info()
info(`${chalk.yellow('>>')} 开始依次执行命令...`)
info()
/**
* 执行命令
*/
gitCmds(desc).forEach(cmd => {
info(`开始执行 ${chalk.cyanBright(cmd)} 命令`)
const spinner = ora({ text: '正在执行命令中...', color: 'yellow' })
spinner.start()
execSync(cmd, { cwd: process.cwd() })
spinner.succeed(`${chalk.green(cmd)} 命令执行成功`)
info()
})
gitCmds(desc).forEach(execCommand)
success('全部命令执行完成')
info()
}
Expand All @@ -44,19 +46,7 @@ export const simplifyBuild = async (cmd: string, desc = '打包') => {
info()
info(`${chalk.yellow('>>')} 开始依次执行命令...`)
info()

/**
* 执行命令
*/
buildCmds(cmd, desc).map(cmd => {
info(`开始执行 ${chalk.cyanBright(cmd)} 命令`)
const spinner = ora({ text: '正在执行命令中...', color: 'yellow' })
spinner.start()
execSync(cmd, { cwd: process.cwd() })
spinner.succeed(`${chalk.green(cmd)} 命令执行成功`)
info()
})

buildCmds(cmd, desc).map(execCommand)
success('全部命令执行完成')
info()
}
Expand All @@ -65,7 +55,11 @@ export const simplifyBuild = async (cmd: string, desc = '打包') => {
* 定义顶级命令的 action
*/
export const handleArguments = (cmd: string, env?: string) => {
/**
* 处理 build[:环境] 命令
*/
if (cmd.includes('build')) return simplifyBuild(cmd, env)

/**
* 输出错误
*/
Expand Down

0 comments on commit ebb66f8

Please sign in to comment.