@@ -207,7 +207,7 @@ async function publishTarball(
207
207
}
208
208
} catch ( error ) {
209
209
// Assume package or version is not published, so just continue and try to publish
210
- log . verbose ( `Caught error: ${ error } ` ) ;
210
+ log . verbose ( `Version appears unpublished; expected error: ${ error } ` ) ;
211
211
}
212
212
213
213
const args = [ "publish" , tarball . fileName , "--access" , "public" ] ;
@@ -216,15 +216,32 @@ async function publishTarball(
216
216
}
217
217
const tarballDirectory = path . dirname ( tarball . filePath ) ;
218
218
log . verbose ( `Executing publish command in ${ tarballDirectory } : pnpm ${ args . join ( " " ) } ` ) ;
219
- const publishOutput = await execa ( "npm" , args , {
220
- cwd : tarballDirectory ,
221
- } ) ;
222
-
223
- if ( publishOutput . exitCode !== 0 ) {
224
- log . warning ( `Failed to publish ${ tarball . name } ` ) ;
225
- log . verbose ( publishOutput . stderr ) ;
226
- return "Error" ;
219
+ try {
220
+ const publishOutput = await execa ( "npm" , args , {
221
+ cwd : tarballDirectory ,
222
+ } ) ;
223
+
224
+ if ( publishOutput . exitCode !== 0 ) {
225
+ return handlePublishError ( log , tarball . name , publishOutput . stderr ) ;
226
+ }
227
+ } catch ( error ) {
228
+ const err = error as Error ;
229
+ return handlePublishError ( log , tarball . name , err . message , err . stack ) ;
227
230
}
228
231
229
232
return "SuccessfullyPublished" ;
230
233
}
234
+
235
+ function handlePublishError (
236
+ log : Logger ,
237
+ name : string ,
238
+ message : string ,
239
+ stack ?: string ,
240
+ ) : "Error" {
241
+ log . warning ( `Failed to publish '${ name } '` ) ;
242
+ log . verbose ( message ) ;
243
+ if ( stack !== undefined ) {
244
+ log . verbose ( stack ) ;
245
+ }
246
+ return "Error" ;
247
+ }
0 commit comments