From 4d64f247412c47473235cdea89b9a4af93913967 Mon Sep 17 00:00:00 2001 From: xiejianxiong Date: Tue, 25 Aug 2020 15:20:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + bin/auto-publish.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 19abb62..2a55513 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ # 使用方式 1. npm link +2. 更改 utils/config.js 文件中的 codePath、buildPath 地址 2. auto p test 发布 测试 test-build 版本 2. auto p pre 发布 预上线 pre-build 版本 2. auto p pro 发布 正式 build 版本 \ No newline at end of file diff --git a/bin/auto-publish.js b/bin/auto-publish.js index 0e8fac5..fbd9a31 100644 --- a/bin/auto-publish.js +++ b/bin/auto-publish.js @@ -5,6 +5,8 @@ const shell = require('shelljs'); const execa = require('execa'); const { Config } = require('../utils/config'); +const buildPath = Config.buildPath; +const codePath = Config.codePath; program.parse(process.argv); const env = program.args[0]; @@ -23,7 +25,7 @@ if (!mappingBranch[env]) { const runBuild = (task) => new Promise(async resolve => { try { - shell.cd(Config.codePath); + shell.cd(codePath); await execa('git', ['checkout', mappingBranch[env].code]); await execa('git', ['pull', 'origin', mappingBranch[env].code]); await execa('npm', ['run', 'build', 'test-build']); @@ -37,12 +39,12 @@ const runBuild = (task) => new Promise(async resolve => { const deleteBuild = (task) => new Promise(async resolve => { try { - shell.cd(Config.buildPath); + shell.cd(buildPath); await execa('git', ['checkout', mappingBranch[env].build]); await execa('git', ['pull', 'origin', mappingBranch[env].build]); - shell.rm(`${Config.buildPath}/*`); - shell.rm('-rf', `${Config.buildPath}/static`); + shell.rm(`${buildPath}/*`); + shell.rm('-rf', `${buildPath}/static`); await execa('git', ['add', '.']); await execa('git', ['commit', '-m', `'发布新版本'`]); @@ -57,9 +59,9 @@ const deleteBuild = (task) => new Promise(async resolve => { const copyBuild = (task) => new Promise(async resolve => { try { - shell.cp('-r', `${Config.codePath}/dist/*`, Config.buildPath); + shell.cp('-r', `${codePath}/dist/*`, buildPath); - shell.cd(Config.buildPath); + shell.cd(buildPath); await execa('git', ['add', '.']); await execa('git', ['commit', '-m', `'发布新版本'`]); await execa('git', ['push', 'origin', mappingBranch[env].build]);