@@ -11,45 +11,37 @@ export async function publish(
1111 context : PublishContext ,
1212) : Promise < void > {
1313 config = await transformAndValidate ( PluginConfig , config ) ;
14-
1514 const releaseDir = path . resolve ( config . releasePath ) ;
1615 const assetDir = path . resolve ( releaseDir , 'assets' ) ;
1716 const versionFile = path . resolve ( releaseDir , 'VERSION' ) ;
1817 const zipCommand = process . env . ZIP_COMMAND ?? 'zip' ;
1918
20- const packageResult = await execa (
21- zipCommand ,
22- [ '-qr' , path . join ( releaseDir , `package.zip` ) , config . slug ] ,
23- {
24- reject : false ,
25- cwd : config . releasePath ,
26- timeout : 30 * 1000 ,
27- } ,
28- ) ;
29-
30- if (
31- ( 'exitCode' in packageResult && packageResult . exitCode !== 0 ) ||
32- ( 'code' in packageResult && packageResult . code !== 0 )
33- ) {
34- throw getError ( 'EZIP' , packageResult . stderr ) ;
35- }
36-
37- if ( config . withAssets ) {
38- const zipResult = await execa (
19+ try {
20+ const packageResult = await execa (
3921 zipCommand ,
40- [ '-qjr ' , path . join ( releaseDir , `assets .zip` ) , assetDir ] ,
22+ [ '-qr ' , path . join ( releaseDir , `package .zip` ) , config . slug ] ,
4123 {
42- reject : false ,
43- cwd : assetDir ,
24+ cwd : config . releasePath ,
4425 timeout : 30 * 1000 ,
4526 } ,
4627 ) ;
47- if (
48- ( 'exitCode' in zipResult && zipResult . exitCode !== 0 ) ||
49- ( 'code' in zipResult && zipResult . code !== 0 )
50- ) {
51- throw getError ( 'EZIP' , zipResult . stderr ) ;
28+
29+ const zipResult = config . withAssets
30+ ? await execa (
31+ zipCommand ,
32+ [ '-qjr' , path . join ( releaseDir , `assets.zip` ) , assetDir ] ,
33+ {
34+ cwd : assetDir ,
35+ timeout : 30 * 1000 ,
36+ } ,
37+ )
38+ : { exitCode : 0 , stderr : '' } ;
39+
40+ if ( packageResult . exitCode !== 0 || zipResult . exitCode !== 0 ) {
41+ throw getError ( 'EZIP' , packageResult . stderr || zipResult . stderr ) ;
5242 }
43+ } catch ( err ) {
44+ throw getError ( err . code ?? 'EZIP' , err . message ) ;
5345 }
5446
5547 if ( config . withVersionFile ) {
0 commit comments