From 108e232afa03af60b760a9b417114dc1286ae042 Mon Sep 17 00:00:00 2001 From: xiejianxiong Date: Thu, 27 Aug 2020 11:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=20commit=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/auto-publish.js | 31 +++++++++++++++++-------------- package.json | 2 +- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/bin/auto-publish.js b/bin/auto-publish.js index 923636c..c89a44f 100644 --- a/bin/auto-publish.js +++ b/bin/auto-publish.js @@ -13,9 +13,9 @@ program.parse(process.argv); const env = program.args[0]; const codeBranchArg = program.args[1]; const buildBranchArg = program.args[2]; -console.log('codeBranchArg: ', codeBranchArg); -console.log('buildBranchArg: ', buildBranchArg); -console.log('env: ', env); + + + const mapping = { 'test': { cmd: 'test-build', codeBranch: 'dev', buildBranch: 'dev_aliyun' }, @@ -23,17 +23,18 @@ const mapping = { 'pro': { cmd: 'build', codeBranch: 'dev', buildBranch: 'develop' }, } -const cmd = mapping[env].cmd; -const codeBranch = codeBranchArg || mapping[env].codeBranch; -const buildBranch = buildBranchArg || mapping[env].buildBranch; -console.log('codeBranch: ', codeBranch); -console.log('buildBranch: ', buildBranch); if (!mapping[env]) { console.log(chalk.red(`not exist ${env} branch`)); return; } +const cmd = mapping[env].cmd; +const codeBranch = codeBranchArg || mapping[env].codeBranch; +const buildBranch = buildBranchArg || mapping[env].buildBranch; + + + const runBuild = (task) => new Promise(async resolve => { try { shell.cd(codePath); @@ -42,7 +43,7 @@ const runBuild = (task) => new Promise(async resolve => { await execa('npm', ['run', cmd]); resolve(); } catch (e) { - console.log('run build error: ', e); + task.skip('Failed run build'); resolve(); } @@ -58,11 +59,12 @@ const deleteBuild = (task) => new Promise(async resolve => { shell.rm('-rf', `${buildPath}/static`); await execa('git', ['add', '.']); - await execa('git', ['commit', '-m', `'自动发布'`]); + const text = `xjx auto publish ${new Date().toLocaleString()}`; + await execa('git', ['commit', '-m', `'${text}'`]); await execa('git', ['push', 'origin', buildBranch]); resolve(); } catch (e) { - console.log('delete build error: ', e); + task.skip('Failed delete build'); resolve(); } @@ -74,11 +76,12 @@ const copyBuild = (task) => new Promise(async resolve => { shell.cd(buildPath); await execa('git', ['add', '.']); - await execa('git', ['commit', '-m', `'自动发布'`]); + const text = `xjx auto publish ${new Date().toLocaleString()}`; + await execa('git', ['commit', '-m', `'${text}'`]); await execa('git', ['push', 'origin', buildBranch]); resolve(); } catch (e) { - console.log('copyBuild error: ', e); + task.skip('Failed copy build'); resolve(); } @@ -100,5 +103,5 @@ const tasks = new Listr([ ]); tasks.run().catch(err => { - console.log(err) + }); \ No newline at end of file diff --git a/package.json b/package.json index 328fa75..5bb2166 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zq_auto_publish", - "version": "1.0.5", + "version": "1.0.6", "description": "", "main": "index.js", "bin": {