@@ -217,54 +217,48 @@ async function publishPackageAndItsMonoPackage(
217217 } ) ;
218218 }
219219
220- // async publish queue & add tag and push
221- const publishQueue = depMonoPackages . map ( item => {
222- return new Promise ( async resolve => {
223- await buildComponent ( item ) ;
224-
225- if ( options . bundle ) {
226- await commandBundle ( { skipLint : true } ) ;
227- }
228-
229- await moveSourceFilesToTempFolderAndPublish (
230- item . name ,
231- options ,
232- item . config ,
233- item . rootPath ,
234- depMap ,
235- isDevelopBranch ,
236- ) ;
237-
238- await addTagAndPush ( generateTag ( item . name , item . packageJson ) , item . packageJson ) ;
239- resolve ( ) ;
220+ try {
221+ const publishQueue = [ ] ;
222+ // async publish & add tag and push
223+ depMonoPackages . map ( item => {
224+ publishQueue . push ( buildComponentAndPublish ( item , options , depMap , isDevelopBranch ) ) ;
240225 } ) ;
241- } ) ;
242226
243- // push current package into publishQueue
244- publishQueue . push (
245- new Promise ( async resolve => {
246- await buildComponent ( targetPackageInfo ) ;
227+ // publish current package
228+ publishQueue . push ( buildComponentAndPublish ( targetPackageInfo , options , depMap , isDevelopBranch ) ) ;
247229
248- if ( options . bundle ) {
249- await commandBundle ( { skipLint : true } ) ;
250- }
251-
252- await moveSourceFilesToTempFolderAndPublish (
253- sourceType ,
254- options ,
255- targetConfig ,
256- targetRoot ,
257- depMap ,
258- isDevelopBranch ,
259- ) ;
230+ return Promise . all ( publishQueue ) ;
231+ } catch ( e ) {
232+ logInfo ( `publish error ${ e } stop publish` ) ;
233+ await fs . remove ( path . join ( pri . projectRootPath , tempPath . dir , declarationPath . dir ) ) ;
234+ await exec ( `git push origin ${ currentBranchName } ` ) ;
235+ return process . exit ( 0 ) ;
236+ }
237+ }
260238
261- await addTagAndPush ( generateTag ( sourceType , targetPackageJson ) , targetPackageJson ) ;
239+ async function buildComponentAndPublish (
240+ packageInfo : PackageInfo ,
241+ options : PublishOption ,
242+ depMap : DepMap ,
243+ isDevelopBranch : boolean ,
244+ ) {
245+ return new Promise ( async resolve => {
246+ await buildComponent ( packageInfo ) ;
262247
263- resolve ( ) ;
264- } ) ,
265- ) ;
248+ if ( options . bundle ) {
249+ await commandBundle ( { skipLint : true } ) ;
250+ }
266251
267- await spinner ( `Publish` , async ( ) => {
268- await Promise . all ( publishQueue ) ;
252+ await moveSourceFilesToTempFolderAndPublish (
253+ packageInfo . name ,
254+ options ,
255+ packageInfo . config ,
256+ packageInfo . rootPath ,
257+ depMap ,
258+ isDevelopBranch ,
259+ ) ;
260+
261+ await addTagAndPush ( generateTag ( packageInfo . name , packageInfo . packageJson ) , packageInfo . packageJson ) ;
262+ resolve ( ) ;
269263 } ) ;
270264}
0 commit comments