@@ -11,45 +11,37 @@ export async function publish(
11
11
context : PublishContext ,
12
12
) : Promise < void > {
13
13
config = await transformAndValidate ( PluginConfig , config ) ;
14
-
15
14
const releaseDir = path . resolve ( config . releasePath ) ;
16
15
const assetDir = path . resolve ( releaseDir , 'assets' ) ;
17
16
const versionFile = path . resolve ( releaseDir , 'VERSION' ) ;
18
17
const zipCommand = process . env . ZIP_COMMAND ?? 'zip' ;
19
18
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 (
39
21
zipCommand ,
40
- [ '-qjr ' , path . join ( releaseDir , `assets .zip` ) , assetDir ] ,
22
+ [ '-qr ' , path . join ( releaseDir , `package .zip` ) , config . slug ] ,
41
23
{
42
- reject : false ,
43
- cwd : assetDir ,
24
+ cwd : config . releasePath ,
44
25
timeout : 30 * 1000 ,
45
26
} ,
46
27
) ;
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 ) ;
52
42
}
43
+ } catch ( err ) {
44
+ throw getError ( err . code ?? 'EZIP' , err . message ) ;
53
45
}
54
46
55
47
if ( config . withVersionFile ) {
0 commit comments