@@ -114,7 +114,8 @@ async function runDeploy(api, { args, deployConfig, deployDir, gitURL, gitBranch
114114
115115 if ( bModify ) {
116116 spinner . text = 'Push files...' ;
117- await gitPush ( api , { args, deployConfig, deployDir, gitURL, gitBranch, commitHash, gitUser, gitMessage, name : MICRO_APP_CONFIG_NAME , currBranch } ) ;
117+ const params = { args, deployConfig, deployDir, gitURL, gitBranch, commitHash, gitUser, gitMessage, name : MICRO_APP_CONFIG_NAME , currBranch } ;
118+ await gitPush ( api , params ) ;
118119 spinner . succeed ( chalk . green ( 'Success!' ) ) ;
119120 } else {
120121 spinner . succeed ( chalk . yellow ( 'NOT MODIFIED!' ) ) ;
@@ -126,7 +127,8 @@ async function runDeploy(api, { args, deployConfig, deployDir, gitURL, gitBranch
126127 return false ;
127128}
128129
129- module . exports = async function deployCommit ( api , args , deployConfigs ) {
130+ module . exports = async function deployCommit ( api , args , deployConfig ) {
131+
130132 const logger = api . logger ;
131133 const root = api . root ;
132134
@@ -135,49 +137,46 @@ module.exports = async function deployCommit(api, args, deployConfigs) {
135137 }
136138
137139 // TODO 迁移到外部,且不中断(分成不同组类型,批量部署)
138- return Promise . all ( deployConfigs . map ( async ( deployConfig , index ) => {
139-
140- const gitURL = deployConfig . url || '' ;
141- if ( _ . isEmpty ( gitURL ) ) {
142- logger . warn ( 'repository is required!' ) ;
143- return ;
144- }
145- const gitBranch = getGitBranch ( deployConfig ) ;
146- if ( _ . isEmpty ( gitBranch ) ) {
147- logger . warn ( 'branch is required!' ) ;
148- return ;
149- }
150- const gitUser = getGitUser ( deployConfig ) ;
140+ const gitURL = deployConfig . url || '' ;
141+ if ( _ . isEmpty ( gitURL ) ) {
142+ logger . warn ( 'repository is required!' ) ;
143+ return ;
144+ }
145+ const gitBranch = getGitBranch ( deployConfig ) ;
146+ if ( _ . isEmpty ( gitBranch ) ) {
147+ logger . warn ( 'branch is required!' ) ;
148+ return ;
149+ }
150+ const gitUser = getGitUser ( deployConfig ) ;
151151
152- const currBranch = getCurrBranch ( deployConfig ) ;
152+ const currBranch = getCurrBranch ( deployConfig ) ;
153153
154- const commitHash = getCommitHash ( ) ;
155- if ( _ . isEmpty ( commitHash ) ) {
156- logger . warn ( 'Not Found commit Hash!' ) ;
157- return ;
158- }
154+ const commitHash = getCommitHash ( ) ;
155+ if ( _ . isEmpty ( commitHash ) ) {
156+ logger . warn ( 'Not Found commit Hash!' ) ;
157+ return ;
158+ }
159159
160- const gitMessage = getGitMessage ( api , { deployConfig, commitHash } ) ;
160+ const gitMessage = getGitMessage ( api , { deployConfig, commitHash } ) ;
161161
162- const gitRoot = path . resolve ( root , CONSTANTS . GIT_NAME ) ;
163- if ( ! fs . existsSync ( gitRoot ) ) {
164- fs . mkdirpSync ( gitRoot ) ;
165- }
166- const deployDir = path . resolve ( gitRoot , CONSTANTS . GIT_SCOPE_NAME ) ;
162+ const gitRoot = path . resolve ( root , CONSTANTS . GIT_NAME ) ;
163+ if ( ! fs . existsSync ( gitRoot ) ) {
164+ fs . mkdirpSync ( gitRoot ) ;
165+ }
166+ const deployDir = path . resolve ( gitRoot , CONSTANTS . GIT_SCOPE_NAME ) ;
167167
168- const params = { args, deployConfig, deployDir, gitURL, gitBranch, commitHash, gitUser, gitMessage, currBranch } ;
169- const bSuccessful = await runDeploy ( api , params ) ;
168+ const params = { args, deployConfig, deployDir, gitURL, gitBranch, commitHash, gitUser, gitMessage, currBranch } ;
169+ const bSuccessful = await runDeploy ( api , params ) ;
170170
171- // 清空
172- if ( fs . existsSync ( deployDir ) ) {
173- fs . removeSync ( deployDir ) ;
174- }
171+ // 清空
172+ if ( fs . existsSync ( deployDir ) ) {
173+ fs . removeSync ( deployDir ) ;
174+ }
175175
176- if ( ! bSuccessful ) {
177- logger . error ( ` Fail${ index && ` [ ${ index } ]` } ! Check your config, please!` ) ;
178- process . exit ( 1 ) ;
179- }
176+ if ( ! bSuccessful ) {
177+ logger . error ( ' Fail! Check your config, please!' ) ;
178+ process . exit ( 1 ) ;
179+ }
180180
181- return params ;
182- } ) ) ;
181+ return params ;
183182} ;
0 commit comments